k8s笔记之chartmuseum搭建
一、下载安装包
#在master节点中执行,以下这条命令就是下载文件到当前目录而已,下载完成之后让我们将chartmuseum赋予权限,就是可执行了chmod 777 chartmuseum,然后移动到/usr/local/bin。 [root@k8s-master-155-221 ~]# curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/linux/amd64/chartmuseum [root@k8s-master-155-221 ~]# chmod 777 chartmuseum [root@k8s-master-155-221 ~]# mv chartmuseum /usr/local/bin
二、创建服务配置和启动文件
服务启动文件
[root@k8s-master-155-221 ~]# vim /etc/systemd/system/chartmuseum.service [Unit] Description=chartmuseum Requires=network-online.target After=network-online.target [Service] EnvironmentFile=/etc/chartmuseum/chartmuseum.config User=root Restart=allways ExecStart=/usr/local/bin/chartmuseum $ARGS ExecStop=/usr/local/bin/chartmuseum step-down [Install] WantedBy=multi-user.target
服务配置文件
[root@k8s-master-155-221 ~]# mkdir /etc/chartmuseum/ [root@k8s-master-155-221 ~]# vim /etc/chartmuseum/chartmuseum.config ARGS=\ --port=8080 \ #服务提供的端口 --storage="local" \ #存储类型 这里使用本地 --storage-local-rootdir="/var/lib/chartmuseum/chartstorage" \ #本地存储chart的路径 --log-json \ --basic-auth-user=admin \ #登录的账号秘密 --basic-auth-pass="123456"
启动服务
[root@k8s-master-155-221 ~]# systemctl start chartmuseum [root@k8s-master-155-221 ~]# systemctl status chartmuseum
三、配置helm使用chartmuseum
1.安装helm-push
插件,指定helm-push路径
如果使用helm进行推送需要在本地安装一个插件,仓库:https://github.com/Coding/helm-push, 执行以下命令安装插件 [root@k8s-master-155-221 ~]# helm plugin install https://github.com/chartmuseum/helm-push
2.添加chartmuseum仓库 注意防火墙开放端口
[root@k8s-master-155-221 ~]# helm repo add chartmuseum http://172.16.155.221:8080 --username admin --password 123456 "chartmuseum" has been added to your repositories
3.测试是否可以上传
[root@k8s-master-155-221 ~]# helm search redis [root@k8s-master-155-221 ~]# helm install stable/redis [root@k8s-master-155-221 ~]# ll .helm/cache/archive/ -rw-r--r-- 1 root root 6189 2019-12-13 13:55 redis-1.1.15.tgz [root@k8s-master-155-221 ~]# helm push redis-1.1.15.tgz chartmuseum Pushing redis-1.1.15.tgz to chartmuseum... Done.
4.查看仓库信息
[root@k8s-master-155-221 ~]# curl -u admin:123456 http://172.16.155.221:8080/api/charts {"demo":[{"name":"demo","version":"0.1.0","description":"A Helm chart for Kubernetes","apiVersion":"v1","appVersion":"1.0","urls":["charts/demo-0.1.0.tgz"],"created":"2019-12-13T15:07:40.27781012+08:00","digest":"38658e69ea5b461904eaf946ea2b82debd3a07eb55226dd6fcfeb74f1fe6088e"}]}
"一劳永逸" 的话,有是有的,而 "一劳永逸" 的事却极少