Blu*_*leu 9 go-templates kubernetes kubernetes-helm
I'm setting up a ConfigMap for my Helm chart.
As per good practice, I want to include non-yaml resources through separate files rather than inline. Currently I am trying to include both an xml file and a tpl helper in my ConfigMap under "data". Both are read without issue in the below code. But I cannot seem to make the indentation for the keys work properly.
My ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "name" . }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ quote .Release.Name }}
heritage: {{ quote .Release.Service }}
name: {{ template "name" . }}
data:
logback.xml: |-
{{- .Files.Get "application-resources/logback.xml" | nindent 8 -}}
application.yml: |-
{{- include "application.yml" . | nindent 8 -}}
Run Code Online (Sandbox Code Playgroud)
This produces the following indentation (actual values are removed for readability):
apiVersion: v1
kind: ConfigMap
metadata:
name: erklaering-anden-lov-detektor-app
labels:
app: name-of-app
chart: name-of-chart
release: "release-name"
heritage: "Tiller"
name: name-of-app
data:
logback.xml: |-
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<xml-stuff>
</configuration>
application.yml: |-
application.yml.contents
Run Code Online (Sandbox Code Playgroud)
Which should be:
apiVersion: v1
kind: ConfigMap
metadata:
name: erklaering-anden-lov-detektor-app
labels:
app: name-of-app
chart: name-of-chart
release: "release-name"
heritage: "Tiller"
name: name-of-app
data:
logback.xml: |-
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<xml-stuff>
</configuration>
application.yml: |-
application.yml.contents
Run Code Online (Sandbox Code Playgroud)
I'm at my wit's end. What am I doing wrong? How do I make yaml snap back to recognizing configMap's own indentation and/or explicitly control it?
Cro*_*rou 12
尝试这个:
data:
logback.xml: |-
{{- .Files.Get "application-resources/logback.xml" | nindent 8 }}
application.yml: |-
{{- include "application.yml" . | nindent 8 -}}
Run Code Online (Sandbox Code Playgroud)
我已经从第三行中删除了“-”,因为它删除了后面的空格。
您还可以查看此 GitHub 问题#3470。
如果需要更多帮助,可以查看Chart Development Tips and Tricks的文档
| 归档时间: |
|
| 查看次数: |
8936 次 |
| 最近记录: |