背景说明
要创建一个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: v1
name: chart-demo
version: 1.0.0
文件结构
[root@cka-master helm]# tree chart-demo/
chart-demo/
├── Chart.yaml
└── templates
1 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]# ls
chart-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]# ls
chart-demo repo
[root@cka-master helm]# cd repo/
[root@cka-master repo]# ls
chart-demo-1.0.0.tgz
[root@cka-master repo]#
[root@cka-master repo]# helm repo index .
[root@cka-master repo]# ls
chart-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 nginx
cf1a251ad6e0e979f016d41841f8b59c78d4ccf028fd0ed32fcaae01ae0f7a01
[root@cka-master helm]# curl 127.0.0.1:8600/index.yaml
apiVersion: v1
entries:
chart-demo:
- apiVersion: v1
created: "2022-03-15T19:57:58.934564044+08:00"
digest: a7b6afa5850d9897acfbf1e43be4cec6ca78bf671c2f2c18783a7ef0053fc3a6
name: chart-demo
urls:
- chart-demo-1.0.0.tgz
version: 1.0.0
generated: "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-demo
NAME CHART VERSION APP VERSION DESCRIPTION
my-repo/chart-demo 1.0.0
[root@cka-master helm]#
[root@cka-master helm]# helm install web-nginx my-repo/chart-demo
NAME: web-nginx
LAST DEPLOYED: Tue Mar 15 20:12:14 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
[root@cka-master helm]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
web-nginx default 1 2022-03-15 20:12:14.393444802 +0800 CST deployed chart-demo-1.0.0