Write Helm Chart by yourself

1. Build a Helm Chart

helm create mychart
tree mychart/

Insert picture description here

cd mychart/
vim Chart.yaml  #编写mychart的应用描述信息,修改app版本,和包版本
vim values.yaml  #编写应用部署信息

Insert picture description here

helm lint mychart/  #检查依赖和模板配置是否正确
helm package mychart/  #打包
helm install demo mychart-1.1.0.tgz  #安装

Insert picture description here

拉伸
helm show values mychart  #查看变量定义的值
helm upgrade demo mychart-1.1.0.tgz --set replicaCount=3
helm history demo

Insert picture description here

2. Establish a local chart warehouse

helm-push plugin download

1.安装helm-push插件
get helm-push_0.9.0_linux_amd64.tar.gz
helm env  #获取插件目录
mkdir -p /root/.local/share/helm/plugins/push
tar zxf helm-push_0.9.0_linux_amd64.tar.gz -C /root/.local/share/helm/plugins/push

TLS仓库
cd /etc/docker/certs.d/reg.westos.org/
cp ca.crt /etc/pki/ca-trust/source/anchors/
update-ca-trust

2.添加本地仓库
helm repo add test1 https://reg.westos.org/chartrepo/charts
helm repo list

Insert picture description here

3.上传
helm push mychart-1.1.0.tgz test1 --insecure -u admin -p westos
helm repo update
helm search repo mychart  #查看上传的mychart应用

Insert picture description here
Insert picture description here

3. Local warehouse deployment

4.本地仓库部署
helm install demo1 test1/mychart --set replicaCount=3
curl 10.108.235.191
curl 10.108.235.191/hostname.html

Insert picture description here
Insert picture description here

5.升级 app后端服务版本
helm upgrade demo1 test1/mychart --set image.tag=v2

Insert picture description here

6.升级整个包版本
vim /root/helm/mychart/values.yaml

Insert picture description here
Insert picture description here
vim /root/helm/mychart/Chart.yaml
Insert picture description here

7.打包上传
helm package mychart/
helm push mychart-2.1.0.tgz test1 --insecure -u admin -p westos
helm repo update
helm search repo mychart -l

8.更新
kubectl get all -n ingress-nginx  #ingress+metallb使其暴露在外网
helm upgrade demo1 test1/mychart

Insert picture description here
Insert picture description here
Insert picture description here

9.测试,外部访问
vim /etc/hosts
172.25.2.101 test.westos.org
curl test.westos.org

Insert picture description here

10.回滚
helm history demo1
helm rollback demo1 1  #1版本没有对外暴露服务,只能集群内访问
kubectl get svc
curl 10.108.235.191

Insert picture description here
The previously deployed metrics, nfs-client-provisioner, can also be deployed with helm

Guess you like

Origin blog.csdn.net/qq_49564346/article/details/114383312