helm install --debug --dry-run qqai-helm-demo ./qqai-helm模板函数与管道符引用上述的案例吧
cat /root/qqai-helm/values.yaml <<EOFbanben: v1shuiguo: applemingzi:name: zhangsanEOFcat /root/qqai-helm/configmap.yaml <<EOFapiVersion: {{ .Values.banben}}kind: ConfigMapmetadata:name: {{ .Release.Name }}-configmapdata:myvalue: "Hello World"name: {{ .Values.mingzi.name }}fruit: {{ .Values.shuiguo }}EOF若将上述案例添加相关的函数,可以像下面这样的做法
cat /root/qqai-helm/values.yaml <<EOFbanben: v1shuiguo: applemingzi:name: zhangsanEOFcat /root/qqai-helm/configmap.yaml <<EOFapiVersion: {{ .Values.banben}}kind: ConfigMapmetadata:name: {{ .Release.Name }}-configmapdata:myvalue: "Hello World"name: {{ .Values.mingzi.name |repeat 5 }}age: {{ .Values.mingzi.age |default "18" }}fruit: {{ .Values.shuiguo | upper | quote}}EOF流程控制概述可以通过流程控制来控制helm的逻辑流程,保证部署的正确性 。
流程控制-if/else: 如果或者基本格式
{{ if PIPELINE }}# Do something{{ else if OTHER PIPELINE }}# Do something{{ else }}# Default case{{ end }}范例
还是请我们老演员登场
cat /root/qqai-helm/values.yaml <<EOFbanben: v1shuiguo: applemingzi:name: zhangsan# age: 30EOFcat /root/qqai-helm/configmap.yaml <<EOFapiVersion: {{ .Values.banben}}kind: ConfigMapmetadata:name: {{ .Release.Name }}-configmapdata:myvalue: "Hello World"name: {{ .Values.mingzi.name |repeat 5 }}age: {{ .Values.mingzi.age |default "18" }}fruit: {{ .Values.shuiguo | upper | quote}}{{ if eq .Values.mingzi.age "30" }}mug: "true"{{ end }}EOF流程控制-with: 指定一个范围这里需要一个范例来解释下with的具体含义
cat /root/qqai-helm/values.yaml <<EOFmingzi:name: zhangsanage: tenEOFcat /root/qqai-helm/configmap.yaml <<EOFapiVersion: {{ .Values.banben}}kind: ConfigMapmetadata:name: {{ .Release.Name }}-configmapdata:myvalue: "Hello World"{{- with .Values.mingzi }}name: {{ .name|default "lisi"|quote }}age: {{ .age |upper|quote }}{{- end }}EOF错误示范:
cat /root/qqai-helm/configmap.yaml <<EOFapiVersion: {{ .Values.banben}}kind: ConfigMapmetadata:name: {{ .Release.Name }}-configmapdata:myvalue: "Hello World"{{- with .Values.mingzi }}name: {{ .name|default "lisi"|quote }}age: {{ .age |upper|quote }}release: {{ .Release.Name }}{{- end }}EOF流程控制-range: For循环下面演示range如何循环起来
Values.yaml
cat /root/qqai-helm/values.yaml <<EOFmingzi:name: zhangsanage: tenjob:- sales- engineer- guestserverEOFconfigmap.yaml
cat /root/qqai-helm/configmap.yaml <<EOFapiVersion: v1kind: ConfigMapmetadata:name: {{ .Release.Name }}data:config: prometheus{{- with .Values.mingzi }}name: {{ mingzi|upper }}{{- end}}group: |-{{- range .Values.job }}- {{ .|title|quote }}{{- end}}EOFHelm之变量--Variables下面一个示范教你如何来定义变量
# 普通的定义cat /root/qqai-helm/configmap.yaml <<EOFapiVersion: v1kind: ConfigMapmetadata:name: {{ .Release.Name }}-configmapdata:config: "hello world"{{- $relname :=.Release.Name -}}{{- with .Values.favorite }}drink: {{ .drink|default "coka" |quote }}release: {{ $relname }}{{- end}}Templates下面案例可以告诉你怎么定义这个模板
# 定义一个模板{{- define "qqai-helm.labels" }}labels:generator: helmdate: {{ now | htmlDate }}{{- end }}apiVersion: v1kind: ConfigMapmetadata:name:{{ .Release.Name }}-configmap# 此处引用模板{{- template "qqai-helm-labels" }}data:myvalue: "hello world"一定注意格式,一定注意格式,一定注意格式NOTES.txt帮助信息,在安装时可以提醒用户如何操作,随便写写就好,要让用户明白即可 。
最后希望大家在写的过程中一定注意格式!注意格式!注意格式!第一次写,希望各位有所收货 。
【Helm干货!速度围观!】
经验总结扩展阅读
- iqooz3充电速度_iqooz3的充电速度多快
- 海味干货批发进货渠道
- 干货批发市场进货渠道有哪些
- 干货批发市场进货渠道哪里最便宜
- 云原生之旅 - 5)Kubernetes时代的包管理工具 Helm
- 飞行速度最快的动物
- 世界上移动速度最快的蛇是什么蛇 世界上移动速度最快的蛇排行榜
- 日日顺物流速度怎么样 日日顺物流投诉电话是多少
- 手把手教你玩转 Gitea|使用 Helm 在 K3s 上安装 Gitea
- FeatureTeam 干货|什么是特性团队/功能团队