douzepao0281 2017-12-04 21:21
浏览 83
已采纳

头盔:使用“ include”进行模板制作时,多余的换行符

I get a weird new line when my chart is rendered that templates from another file using {{ include }}. For instance, my manifest looks like this

      containers:
      - name: {{ .Release.Name }}
        image: {{ .Values.global.image}}:{{ .Values.global.imageTag }}
        imagePullPolicy: {{ .Values.global.pullPolicy }}
        ports:
          - containerPort: {{ .Values.gloabl.containerPort }}
{{ include "common_deployment" . }}

and my common_deployment is defined as

{{- define "common_deployment" }}
        envFrom:
          - secretRef:
              name: {{ .Release.Name }}-secret
{{- end -}}

when I look at my manifest after doing a dry run on Helm, my template looks something like this

 containers:
  - name: test
    image: myrepo/myimage:latest
    imagePullPolicy: Always
    ports:
      - containerPort: 4444

envFrom:
  - secretRef:
      name: test-secret

Notice how there is a new lie between the ports and the envFrom. I'm wondering if this will affect how my pods will turn out because there are issues with volumes being mounted and I want to be able to make sure that this templating problem is the culprit before going down another rabbit hole.

  • 写回答

1条回答 默认 最新

  • douqie3391 2017-12-04 21:44
    关注

    You can use a hyphen to suppress the newline on template commands. You're already using it for define and end.

    Similarly, you should use {{- include ... -}}.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog