我的deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: foo
labels:
app: foo
spec:
selector:
matchLabels:
app: foo
template:
metadata:
labels:
app: foo
spec:
{{- include "pod" . | nindent 6 }}我的_pod.tpl
{{- define "pod" -}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 2 }}
{{- end }}
serviceAccountName: foo
containers:
- name: foo
image: nginx:latest
{{- end }}给我:
# Source: foo/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: foo
labels:
app: foo
spec:
selector:
matchLabels:
app: foo
template:
metadata:
labels:
app: foo
spec:
imagePullSecrets:
- name: bar
serviceAccountName: foo
containers:
- name: foo
image: nginx:latest为什么在spec:之后有一个空行
编辑的
但是,在部署中使用{{- include "pod" . | indent 6 }}时没有空行,但是在spec:之后有6个空白空间,如:spec:。
发布于 2021-05-24 11:05:11
-- indent函数与缩进函数相同,但在字符串的开头加上新行。
参考:https://helm.sh/docs/chart_template_guide/function_list/#nindent
您应该使用indent而不是nindent,以避免在spec:之后出现新行
https://stackoverflow.com/questions/67620863
复制相似问题