helm中nindent的用法 helm中nindent的用法 Helm模板引擎中的nindent函数用于处理文本缩进问题,核心功能是生成带换行符的缩进字符串,确保YAML文件结构正确。该函数与indent的区别在于,nindent会在文本块前自动添加换行符,这对生成复杂嵌套的YAML内容尤为重要。假设需要为KubernetesConfigMap生成多行配置,直接写文本会导致...
indent:缩进 {{ indent 4 .Values.hello }}# 注意,hello必须是string,如果是数字,则报错,此时可以结合quote{{ quote .Values.hello | indent 4 }} nindent:新换行,再缩进,并且只能处理字符串,而且不能用# ReleaseName:{{ indent 2 .Release.Name }}ReleaseNamespace:{{ nindent 2 .Release.Namespace }}...
{{- if .Values.serviceAccount.create -}}apiVersion: v1kind: ServiceAccountmetadata: name: {{ include "your-chart.serviceAccountName" . }} labels: {{- include "your-chart.labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . ...
问helm模板在使用nindent时添加空行EN在定义 JSON 数据时,我们通常会将 Data 和 Schema 分开处理。而 ...
5.16 indent 5.17 nindent 5.18 replace 5.19 default 六、Helm流程控制 6.1 If/Else 6.2 控制空格 6.3 修改使用with的范围 6.4 使用range操作循环 O、致谢 感谢宽哥的介绍和分享,让我逐渐入门k8s,帮助我打开了云原生领域的大门,著有《再也不踩坑的kubernetes实战指南》、《云原生Kubernetes全栈架构师实战》。如果大...
管道及方法trunc表示字符串截取,63作为参数传递给trunc方法,trimSuffix表示去掉-后缀{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}nindent表示前面的空格数 selector: matchLabels: {{- include "nginx.selectorLabels" . | nindent 6 }}lower表示将内容小写,quote表示用双引号引起来value: {...
16、nindent 17、replace 18、date 4)类型转换函数 5)正则表达式(Regular Expressions) 6)编码和解码函数 7)Dictionaries and Dict Functions 1、创建字典(dict) 2、获取值(get) 3、添加键值对(set) 4、删除(unset) 5、判断key(hasKey) 6、pluck
nindent 4:表示首行缩进4个字母 TRUNC(NUMBER)表示截断数字 4. values.yaml文件编写 [root@k8s-master1 myapp]# cat values.yaml # Default values for myapp. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicaCount: 1 image: repository: nginx pullPolicy...
nindent 2:缩进2个字母,用于yaml文件格式化 b64enc:转换成base-64 now:当前时间 htmlDate: 格式化时间为2016-11-02 default: default函数,设置默认值,{{ .Values.favorite.drink | default "tea" | quote }},如果vaules文件里不存在drink值,将采用默认值 “ tea ”。
nindent 2:缩进2个字母,用于yaml文件格式化 b64enc:转换成base-64 now:当前时间 htmlDate: 格式化时间为2016-11-02 default: default函数,设置默认值,{{ .Values.favorite.drink | default "tea" | quote }},如果vaules文件里不存在drink值,将采用默认值 “ tea ”。