#作者:程宏斌
文章目錄
- 自定義helm模板
- 1、開發自己的chare包
- 2、調試chart
- 3、安裝chart
自定義helm模板
https://hub.helm.sh/
1、開發自己的chare包
[root@master ~]# helm create mychare
//創建一個名為mychare的chare包
[root@master ~]# tree -C mychare/
//以樹狀圖查看一下chare包
mychare/
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
2、調試chart
[root@master mychare]# cd
[root@master ~]# helm install --dry-run --debug mychare
//檢查這個mychare是否有問題
3、安裝chart
[root@node02 ~]# docker pull nginx:stable
(1)通過倉庫安裝
[root@master mychare]# helm search redis
//搜索chare包
[root@master mychare]# helm repo list
//查看是否有能訪問倉庫
[root@master mychare]# helm install stable/redis
//安裝
(2)通過tar包安裝
[root@master ~]# helm fetch stable/redis
//直接下載chare包
[root@master ~]# tar -zxf redis-1.1.15.tgz
//解壓下載的chare包
[root@master ~]# tree -C redis
redis
├── Chart.yaml
├── README.md
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── networkpolicy.yaml
│ ├── NOTES.txt
│ ├── pvc.yaml
│ ├── secrets.yaml
│ └── svc.yaml
└── values.yaml
(3)通過chare本地目錄安裝
[root@master ~]# helm fetch stable/redis
//直接下載chare包
[root@master ~]# tar -zxf redis-1.1.15.tgz
//解壓下載的chare包
[root@master ~]# helm install redis
(4)通過URL安裝
[root@master ~]# helm install https://example.com/charts/foo-1.2.3.tgz
(5)使用本地目錄安裝:
[root@master ~]# cd mychare/
[root@master mychare]# vim values.yaml
[root@master mychare]# cd templates/
[root@master templates]# vim service.yaml
[root@master templates]# cd ..
[root@master mychare]# helm install -n test ../mychare/
[root@master ~]# helm upgrade test mychare/ -f mychare/values.yaml
4、例子
使用mychart部署一個實例: xgp。使用鏡像為私有鏡像v1 版本。
完成之后,鏡像版本。
全部成功之后,將實例做一個升級,將鏡像改為v2版本。
更改鏡像為私有鏡像
[root@master ~]# vim mychare/values.yaml
[root@master ~]# helm install -n xgp mychare/ -f mychare/values.yaml
[root@master ~]# kubectl get deployments. -o wide
[root@master ~]# vim mychare/values.yaml
[root@master ~]# helm upgrade xgp mychare/ -f mychare/values.yaml
[root@master ~]# kubectl get deployments. -o wide
[root@master ~]# kubectl edit deployments. xgp-mychare
[root@master ~]# kubectl get deployments. -o wide