一、下载安装包
#在master节点中执行,以下这条命令就是下载文件到当前目录而已,下载完成之后让我们将chartmuseum赋予权限,就是可执行了chmod chartmuseum,然后移动到/usr/local/bin。
[root@k8s-master-- ~]# curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/linux/amd64/chartmuseum
[root@k8s-master-- ~]# chmod chartmuseum
[root@k8s-master-- ~]# mv chartmuseum /usr/local/bin
二、创建服务配置和启动文件
服务启动文件
[root@k8s-master-- ~]# 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-- ~]# mkdir /etc/chartmuseum/
[root@k8s-master-- ~]# vim /etc/chartmuseum/chartmuseum.config
ARGS=\
--port= \ #服务提供的端口
--storage="local" \ #存储类型 这里使用本地
--storage-local-rootdir="/var/lib/chartmuseum/chartstorage" \ #本地存储chart的路径
--log-json \
--basic-auth-user=admin \ #登录的账号秘密
--basic-auth-pass=""
启动服务
[root@k8s-master-- ~]# systemctl start chartmuseum
[root@k8s-master-- ~]# systemctl status chartmuseum
三、配置helm使用chartmuseum
1.安装helm-push
插件,指定helm-push路径
如果使用helm进行推送需要在本地安装一个插件,仓库:https://github.com/Coding/helm-push, 执行以下命令安装插件
[root@k8s-master-- ~]# helm plugin install https://github.com/chartmuseum/helm-push
2.添加chartmuseum仓库 注意防火墙开放端口
[root@k8s-master-- ~]# 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-- ~]# helm search redis
[root@k8s-master-- ~]# helm install stable/redis
[root@k8s-master-- ~]# ll .helm/cache/archive/
-rw-r--r-- root root -- : redis-1.1..tgz
[root@k8s-master-- ~]# helm push redis-1.1..tgz chartmuseum
Pushing redis-1.1..tgz to chartmuseum...
Done.
4.查看仓库信息
[root@k8s-master-- ~]# curl -u admin: 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"}]}