1、ChartMuseum是什么缩焦?
ChartMuseum 是一個(gè)用 Go 語(yǔ)言寫的開(kāi)源的 Helm Chart Repository 服務(wù)器读虏,有多種 API 來(lái)完成對(duì) Helm Chart Repository、Chart 以及 Server 的操作袁滥。所有可用的 API 以及使用方法可查看GitHub Repo盖桥。
2、ChartMuseum的安裝
ChartMuseum安裝可參考官網(wǎng)题翻,支持 gofish揩徊、bash 腳本以及 docker等方式。docker 方式安裝ChartMuseum 實(shí)例,操作如下:
#1塑荒、創(chuàng)建宿主機(jī)目錄熄赡,使用local本地存儲(chǔ)chart包
mkdir /opt/charts
#2、docker run 方式啟動(dòng)ChartMuseum
docker run -d \
-p 8180:8080 \
-e DEBUG=1 \
-e STORAGE=local \
-e STORAGE_LOCAL_ROOTDIR=/charts \
-v /opt/charts:/charts \
chartmuseum/chartmuseum:latest
#3齿税、使用 curl 測(cè)試下接口彼硫,沒(méi)有報(bào)錯(cuò)表示成功
curl localhost:8180/api/charts
安裝完成后,可通過(guò)瀏覽器訪問(wèn)http://hostIP:8180鏈接進(jìn)入主頁(yè)凌箕。
3拧篮、ChartMuseum的使用
安裝helm3,添加官方源牵舱,獲取公共倉(cāng)庫(kù)chart
helm repo add az-stable http://mirror.azure.cn/kubernetes/charts/
安裝helm push插件串绩,支撐本地chart上傳私有chart倉(cāng)庫(kù)
helm plugin install https://github.com/chartmuseum/helm-push.git
添加私有chart倉(cāng)庫(kù),到helm repo列表仆葡,如chartmuseum的hostIP為192.168.211.13如下:
helm repo add local http://192.168.211.13:8180
下載公共chart到本地目錄赏参,如mysql志笼、tomcat如下:
helm pull az-stable/mysql
helm pull az-stable/tomcat
推送chart到私有倉(cāng)庫(kù)沿盅,并查看
root@qa-opreator:~# ls
mysql-1.6.9.tgz tomcat-0.4.3.tgz
root@qa-opreator:~# helm cm-push mysql-1.6.9.tgz local
Pushing mysql-1.6.9.tgz to local...
Done.
root@qa-opreator:~# helm cm-push tomcat-0.4.3.tgz local
Pushing tomcat-0.4.3.tgz to local...
Done.
root@qa-opreator:~# helm search repo local
NAME CHART VERSION APP VERSION DESCRIPTION
local/mysql 1.6.9 5.7.30 DEPRECATED - Fast, reliable, scalable, and easy...
local/tomcat 0.4.3 7.0 DEPRECATED - Deploy a basic tomcat application ...
刪除一個(gè) Chart,調(diào)用/api/charts/<name>/<version>接口即可
root@qa-opreator:~# curl -X DELETE http://localhost:8180/api/charts/tomcat/0.4.3
{"deleted":true}
使用私有倉(cāng)庫(kù)纫溃,可將http://192.168.211.13:8180添加到repo列表腰涧,瀏覽器訪問(wèn)http://192.168.211.13:8180/api/charts可查看chart列表。
4紊浩、ChartMuseum其他配置
配置Basic Auth登錄認(rèn)證窖铡,需指定 --basic-auth-user 與 --basic-auth-pass 兩個(gè)參數(shù)即可。訪問(wèn)http://192.168.211.13:8180會(huì)要求輸入登錄信息坊谁,docker run參數(shù)如下:
root@qa-opreator:~# docker run -d \
-p 8180:8080 \
-e DEBUG=1 \
-e STORAGE=local \
-e BASIC_AUTH_USER=admin \
-e BASIC_AUTH_PASS=password \
-e STORAGE_LOCAL_ROOTDIR=/charts \
-v /opt/charts:/charts \
chartmuseum/chartmuseum:latest
啟用https配置费彼,需指定 --tls-cert 與 --tls-key 兩個(gè)參數(shù)。首先口芍,生成一對(duì)cert和key證書如下:
root@qa-opreator:/opt/charts# openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout cm.key -out cm.crt
啟用cert和key證書箍铲,修改docker run參數(shù)如下:
root@qa-opreator:~# docker run -d \
-p 8180:8080 \
-e DEBUG=1 \
-e STORAGE=local \
-e BASIC_AUTH_USER=admin \
-e BASIC_AUTH_PASS=password \
-e TLS_CERT=/charts/cm.crt \
-e TLS_KEY=/charts/cm.key \
-e STORAGE_LOCAL_ROOTDIR=/charts \
-v /opt/charts:/charts \
chartmuseum/chartmuseum:latest
用https://192.168.211.13:8180訪問(wèn),提提示證書警告鬓椭,信任自簽證書即可颠猴。