背景说明
要创建一个Chart仓库非常简单,Chart仓库其实就是一个带有index.html的索引文件和任意个打包的Chart的HTTP服务器。
解决方案
准备Chart
文件创建
[root@cka-master helm]# mkdir chart-demo[root@cka-master helm]# cd chart-demo/[root@cka-master chart-demo]# ls[root@cka-master chart-demo]# mkdir templates
编辑文件Chart.yaml
apiVersion: v1name: chart-demoversion: 1.0.0
文件结构
[root@cka-master helm]# tree chart-demo/chart-demo/├── Chart.yaml└── templates1 directory, 1 file[root@cka-master helm]#
打包Chart
[root@cka-master helm]# helm package chart-demo/Successfully packaged chart and saved it to: /root/helm/chart-demo-1.0.0.tgz[root@cka-master helm]# lschart-demo chart-demo-1.0.0.tgz[root@cka-master helm]#
发布Chart
[root@cka-master helm]# mkdir repo[root@cka-master helm]# mv chart-demo-1.0.0.tgz repo/[root@cka-master helm]# lschart-demo repo[root@cka-master helm]# cd repo/[root@cka-master repo]# lschart-demo-1.0.0.tgz[root@cka-master repo]#[root@cka-master repo]# helm repo index .[root@cka-master repo]# lschart-demo-1.0.0.tgz index.yaml[root@cka-master repo]#[root@cka-master repo]# docker pull nginx[root@cka-master repo]# docker run -p 8600:80 --name helm-repo -d -v /root/helm/repo:/usr/share/nginx/html nginxcf1a251ad6e0e979f016d41841f8b59c78d4ccf028fd0ed32fcaae01ae0f7a01[root@cka-master helm]# curl 127.0.0.1:8600/index.yamlapiVersion: v1entries:chart-demo:- apiVersion: v1created: "2022-03-15T19:57:58.934564044+08:00"digest: a7b6afa5850d9897acfbf1e43be4cec6ca78bf671c2f2c18783a7ef0053fc3a6name: chart-demourls:- chart-demo-1.0.0.tgzversion: 1.0.0generated: "2022-03-15T19:57:58.934175015+08:00"[root@cka-master helm]#
引用Chart
[root@cka-master helm]# helm repo add my-repo http://127.0.0.1:8600"my-repo" has been added to your repositories
验证Chart
[root@cka-master helm]# helm search repo chart-demoNAME CHART VERSION APP VERSION DESCRIPTIONmy-repo/chart-demo 1.0.0[root@cka-master helm]#[root@cka-master helm]# helm install web-nginx my-repo/chart-demoNAME: web-nginxLAST DEPLOYED: Tue Mar 15 20:12:14 2022NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: None[root@cka-master helm]# helm listNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSIONweb-nginx default 1 2022-03-15 20:12:14.393444802 +0800 CST deployed chart-demo-1.0.0
