在编写完chart文件后,我们可以将它发布到公网上,让其他开发者也享用我们的劳动成果,类似于docker hub机制:
Helm repo使用HTTP服务器来托管你的文件,里面包括一个index.yaml
和所有的chart文件。常见的地址有S3, Github, GCP Cloud Storage等对象存储服务,本节将使用Github pages来进行演示。
首先创建一个个人的github仓库:
clone到本地,并创建新的分支:
$ git clone https://github.com/kongpingfan/helm-repo.git
$ cd helm-repo
$ git checkout -b gh-pages
创建一个空的文件并推送到github:
$ touch index.yaml
$ git add index.yaml
$ git commit -a -m "add index.yaml"
$ git push --set-upstream origin gh-pages
如果在推送时遇到遇到github的验证问题,可参考: https://stackoverflow.com/questions/68775869/support-for-password-authentication-was-removed-please-use-a-personal-access-to
在github的Settings => Pages
页面确认Source为gh-pages
:
现在浏览器中可以访问到index.yaml文件:
将chart添加到这个repo:
$ helm package my-app
$ mv my-app-0.1.0.tgz helm-example
$ helm repo index helm-example/ --url https://gree-gorey.github.io/helm-example/
最后一条命令生成了index.yaml
文件:
kongpingfan:~/environment/helm/hooks-lab $ cat helm-repo/index.yaml
apiVersion: v1
entries:
hooks-lab:
- apiVersion: v2
appVersion: 1.16.0
created: "2021-12-19T14:06:38.842320996Z"
description: A Helm chart for Kubernetes
digest: f87d7298af35cbab27a1c81b25e24cc21268c5719b08acc11a6486d6e6d7425c
name: hooks-lab
type: application
urls:
- https://kongpingfan.github.io/helm-repo/hooks-lab-0.1.0.tgz
version: 0.1.0
generated: "2021-12-19T14:06:38.841753139Z"
commit & push:
$ git add .
$ git commit -m "change index"
$ git push origin
确认index.yaml
已经上传到公网:
$ curl https://kongpingfan.github.io/helm-repo/index.yaml
apiVersion: v1
entries:
hooks-lab:
- apiVersion: v2
appVersion: 1.16.0
created: "2021-12-19T14:06:38.842320996Z"
description: A Helm chart for Kubernetes
digest: f87d7298af35cbab27a1c81b25e24cc21268c5719b08acc11a6486d6e6d7425c
name: hooks-lab
type: application
urls:
- https://kongpingfan.github.io/helm-repo/hooks-lab-0.1.0.tgz
version: 0.1.0
generated: "2021-12-19T14:06:38.841753139Z"
现在,我们就可以在任意一台电脑上添加并使用这个Helm repo了!!
$ helm repo add helm-example https://kongpingfan.github.io/helm-repo
$ helm repo list
NAME URL
helm-example https://kongpingfan.github.io/helm-repo
基于这个repo创建新的release:
$ helm install my-release helm-example/hooks-lab
应用也成功部署!
https://medium.com/containerum/how-to-make-and-share-your-own-helm-package-50ae40f6c221