官方文档
1 2 3 4 5
| $ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 $ chmod 700 get_helm.sh $ ./get_helm.sh $ helm version version.BuildInfo{Version:"v3.12.3", GitCommit:"3a31588ad33fe3b89af5a2a54ee1d25bfe6eaa5e", GitTreeState:"clean", GoVersion:"go1.20.7"}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| helm repo add stable https://charts.helm.sh/stable
helm repo add elastic https://helm.elastic.co helm repo add gitlab https://charts.gitlab.io helm repo add harbor https://helm.goharbor.io helm repo add bitnami https://charts.bitnami.com/bitnami helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com helm repo add stable https://kubernetes-charts.storage.googleapis.com
helm repo add stable http://mirror.azure.cn/kubernetes/charts helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts helm repo update
helm repo list
|
常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| brew install helm
helm get values -n namespaseName server-name
helm history -n namespaseName server-name
helm rollback -n namespaseName server-name revision
helm get manifest -n exxk-lab exxk-api-v1
helm get manifest -n exxk-lab exxk-api-v1 | kubectl describe -n exxk-lab -f -
helm upgrade --install my-influxdb influxdata/influxdb --set image.tags=2.5.1-alpine
helm delete my-influxdb
|
模版目录结构
1 2 3 4 5 6 7 8 9 10
| mychart/ Chart.yaml values.yaml charts/ templates/ NOTES.txt deployment.yaml service.yaml _helpers.tpl ...
|
helm upgrade [RELEASE] [CHART] [flags]
常见参数:
-i
, --install
:如果版本不存在就运行安装
--history-max
<int>
:限制每个版本保存的最大修订数。使用 0 表示无限制(默认 10)
-
-n
, --namespace
<string>
:指定命名空间范围
-f
, --values
<strings>
:在 YAML 文件或 URL 中指定值(可以指定多个)
--set
stringArray
: 在命令行设置值(可以用逗号指定多个或单独的值:key1=val1,key2=val2)
1 2 3 4 5 6 7 8 9 10
| CHARTS_REPO = 'https://harbor.exxk.com/chartrepo/baseimage/charts' CHARTS_NAME = 'appchart-uat-latest.tgz' CICD_REGISTRY = 'harbor.exxk.com.cn' HARBOR_NAMESPACE = 'dev-1'
CURRENT_IMAGE=`helm3 get values -n exxk exxk-server-v1 | grep repository | awk -F ': ' '{print \\$2}' `
helm3 upgrade -i --history-max=5 exxk-server-v1 $CHARTS_REPO/$CHARTS_NAME -n exxk -f z-k8s-helm/uat/val-exxk-server.yaml --set image.repository=$CICD_REGISTRY/$HARBOR_NAMESPACE/exxk-server:$CICD_SEQUENCE,currentImage=$CURRENT_IMAGE
|
创建helm chrat
常见语法
1 2 3 4
| {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }}
|
1 2 3 4 5 6 7 8 9 10
| brew install helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 chmod 700 get_helm.sh ./get_helm.sh --version v3.2.4
helm create nginx-file-brower
helm lint mychart
|
常见问题
helm Error: UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress
错误原因:是因为历史更新有未成功的,导致一直Preparing upgrade
解决:执行下面命令回退版本,然后重新跑流水线即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| [root@k8s-master-242-10 ~]# helm history -n namespaseName server-name REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION 12 Wed Jun 1 07:00:04 2022 superseded appchart-uat-latest 1.16.0 Upgrade complete 13 Thu Jun 2 02:01:17 2022 superseded appchart-uat-latest 1.16.0 Upgrade complete 14 Thu Jun 2 02:23:25 2022 pending-upgrade appchart-uat-latest 1.16.0 Preparing upgrade [root@k8s-master-242-10 ~]# helm rollback -n namespaseName server-name 13 Rollback was a success! Happy Helming! [root@k8s-master-242-10 ~]# helm history -n namespaseName server-name REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION 12 Wed Jun 1 07:00:04 2022 superseded appchart-uat-latest 1.16.0 Upgrade complete 13 Thu Jun 2 02:01:17 2022 superseded appchart-uat-latest 1.16.0 Upgrade complete 14 Thu Jun 2 02:23:25 2022 pending-upgrade appchart-uat-latest 1.16.0 Preparing upgrade 15 Tue Jun 28 16:35:18 2022 deployed appchart-uat-latest 1.16.0 Rollback to 13 [root@mh-k8s-master-242-10 ~]#
|