1. Helm 入门
1.1 部署安装
1.2 helm命令的使用
1.3 添加 Chart 源
# 添加常用chart源helm repo add stable https://charts.helm.sh/stablehelm repo add bitnami https://charts.bitnami.com/bitnamihelm repo add aliyuncs https://apphub.aliyuncs.com# 查看chart源[bcpay@localhost ~]$ helm repo listNAME URLstable https://charts.helm.sh/stablealiyuncs https://apphub.aliyuncs.combitnami https://charts.bitnami.com/bitnami
1.4 搜索 Chart
[bcpay@localhost ~]$ helm search repo mysqlNAME CHART VERSION APP VERSION DESCRIPTIONaliyuncs/mysql 6.8.0 8.0.19 Chart to create a Highly available MySQL clusteraliyuncs/mysqldump 2.6.0 2.4.1 A Helm chart to help backup MySQL databases usi...aliyuncs/mysqlha 1.0.0 5.7.13 MySQL cluster with a single master and zero or ...aliyuncs/prometheus-mysql-exporter 0.5.2 v0.11.0 A Helm chart for prometheus mysql exporter with...bitnami/mysql 8.5.0 8.0.23 Chart to create a Highly available MySQL clusterstable/mysql 1.6.9 5.7.30 DEPRECATED - Fast, reliable, scalable, and easy...stable/mysqldump 2.6.2 2.4.1 DEPRECATED! - A Helm chart to help backup MySQL...stable/prometheus-mysql-exporter 0.7.1 v0.11.0 DEPRECATED A Helm chart for prometheus mysql ex.........
1.5 下载 Chart
# 下载chart到本地[bcpay@localhost ~]$ helm pull aliyuncs/mysql --untar# chart目录结构[bcpay@localhost ~]$ tree mysqlmysql├── Chart.yaml # Chart 的相关信息、包括名字、描述信息、版本等├── ci│ └── values-production.yaml├── files│ └── docker-entrypoint-initdb.d│ └── README.md├── README.md├── templates # 模板目录│ ├── _helpers.tpl # 用于存储模板片段│ ├── initialization-configmap.yaml│ ├── master-configmap.yaml│ ├── master-statefulset.yaml│ ├── master-svc.yaml│ ├── NOTES.txt # Chart 部署到集群后的一些信息,例如:如何使用、缺省值│ ├── secrets.yaml│ ├── servicemonitor.yaml│ ├── slave-configmap.yaml│ ├── slave-statefulset.yaml│ └── slave-svc.yaml├── values-production.yaml # 参考values文件└── values.yaml # 重要,模板的值文件,这些值会在安装时应用到 GO 模板中生成部署文件4 directories, 17 files
2. Helm进阶
2.1 自定义Chart
2.1.1 创建Chart模板
[bcpay@localhost ~]$ helm create test01
Creating test01
[bcpay@localhost ~]$ tree test01/
test01/
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── hpa.yaml
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── serviceaccount.yaml
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
3 directories, 10 files
2.2 使用 Harbor 作为 Chart 仓库
2.2.1 安装插件
helm 默认不支持 helm push 命令,需要安装helm-push插件:
helm plugin install https://github.com/chartmuseum/helm-push
2.2.2 添加 Harbor 仓库
Harbor 默认安装不开启 Chart 仓库功能,执行 install.sh 脚本的时候需要加上 —with-chartmuseum
helm repo add harbor http://192.168.0.196/chartrepo/charts --username=admin --password=Harbor12345
2.2.3 推送本地Chart
helm push ./k8s-deploy-h5/ harbor
