Reputation: 5149
I just created a new Helm chart but when I run helm install --dry-run --debug
I get:
Error: YAML parse error on multi-camera-tracking/templates/multi-camera-tracking.yaml: error converting YAML to JSON: yaml: line 30: did not find expected key
And this is my Yaml file:
---
# apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: multi-camera-tracking
annotations:
Process: multi-camera-tracking
labels:
io.kompose.service: multi-camera-tracking
spec:
serviceName: multi-camera-tracking
replicas: 1
selector:
matchLabels:
io.kompose.service: multi-camera-tracking
podManagementPolicy: "Parallel"
template:
metadata:
labels:
io.kompose.service: multi-camera-tracking
spec:
containers:
- name: multi-camera-tracking
env:
- name: MCT_PUB_PORT
value: {{ .Values.MCT_PUB_PORT | quote }}
- name: SCT_IP_ADDR_CSV
value: {{ .Values.SCT_IP_ADDR_CSV | quote }}
- name: SCT_PUB_PORT_CSV
value: {{ .Values.SCT_PUB_PORT1 | quote }}, {{ .Values.SCT_PUB_PORT2 | quote }}
image: {{ .Values.image_multi_camera_tracking }}
ports:
- containerPort: {{ .Values.MCT_PUB_PORT }}
resources:
requests:
cpu: 0.1
memory: 250Mi
limits:
cpu: 4
memory: 10Gi
readinessProbe:
exec:
command:
- ls
- /tmp
initialDelaySeconds: 5
periodSeconds: 60
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
annotations:
Process: multi-camera-tracking
creationTimestamp: null
labels:
io.kompose.service: multi-camera-tracking
name: multi-camera-tracking
spec:
ports:
- name: "MCT_PUB_PORT"
port: {{ .Values.MCT_PUB_PORT }}
targetPort: {{ .Values.MCT_PUB_PORT }}
selector:
io.kompose.service: multi-camera-tracking
status:
loadBalancer: {}
The strange thing is I have created multiple other helm charted and they all are very similar to this but this one doesn't work and produces error.
Upvotes: 16
Views: 97928
Reputation: 3343
My problem was improper indenting. Moral of the story:
When copy-pasting a call to a named template, make sure the indentation is correct.
{{- include "my-template" . | nindent 6 }}
Upvotes: 1
Reputation: 3389
Had a similar error with rendering an xml.
in values.yaml
I had:
xml: >
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="http://www.sso.com/diohadohad">
<md:IDPSSODescriptor WantAuthnRequestsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:KeyDescriptor use="signing">
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Data>
<ds:X509Certificate>JJDHDHASDAIDSFHDSGERGSERGISJDFGSERIGSERGRSG TEImxWRRX87Xj1MZyxjiBQ+ilySMD9OsskTSwVysTwWK+eFM40gVXFWBeAuoQvkb2rvZ2+8rJySQ rYC+dMIfKE6EEwnD6+XzwcKpTjs7TChviMZ6LxNbMJO6ybJPxoJt0zV0Aago9UEAF2U3NVuRTmsE TUOk9mbI14ULcZM03ltjSZqi</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</md:KeyDescriptor>
<md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat>
<md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</md:NameIDFormat>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://mycompany.sso.com/app/asdfasdf/sso/saml"/>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://mycompany.sso.com/app/asdfasdfsdf/sso/saml"/>
</md:IDPSSODescriptor>
</md:EntityDescriptor>
And for some reason I couldn't render this value. I was looking for character that was causing me trouble, and found out it was the double-quote "
char.
Since it's an xml, the quick fix for me was to change this character to a single-quote '
instead:
xml: >
<md:EntityDescriptor xmlns:md='urn:oasis:names:tc:SAML:2.0:metadata' entityID='http://www.sso.com/diohadohad'>
<md:IDPSSODescriptor WantAuthnRequestsSigned='false' protocolSupportEnumeration='urn:oasis:names:tc:SAML:2.0:protocol'>
<md:KeyDescriptor use='signing'>
<ds:KeyInfo xmlns:ds='http://www.w3.org/2000/09/xmldsig#'>
<ds:X509Data>
<ds:X509Certificate>JJDHDHASDAIDSFHDSGERGSERGISJDFGSERIGSERGRSG TEImxWRRX87Xj1MZyxjiBQ+ilySMD9OsskTSwVysTwWK+eFM40gVXFWBeAuoQvkb2rvZ2+8rJySQ rYC+dMIfKE6EEwnD6+XzwcKpTjs7TChviMZ6LxNbMJO6ybJPxoJt0zV0Aago9UEAF2U3NVuRTmsE TUOk9mbI14ULcZM03ltjSZqi</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</md:KeyDescriptor>
<md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat>
<md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</md:NameIDFormat>
<md:SingleSignOnService Binding='urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST' Location='https://mycompany.sso.com/app/asdfasdf/sso/saml'/>
<md:SingleSignOnService Binding='urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect' Location='https://mycompany.sso.com/app/asdfasdfsdf/sso/saml'/>
</md:IDPSSODescriptor>
</md:EntityDescriptor>
Upvotes: 1
Reputation: 41
i had the similar issue, after all the debugging i found out that the issue was with the identation of one of the file, i was referring to in the configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-conf
labels:
{{- include "mytemp.labels" . | nindent 4 }}
data:
{{ (tpl (.Files.Glob "configs/MyJobConf.conf").AsConfig . ) | nindent 4 }}
Identation issue was not in the configmap.yaml but MyJobConf.conf (helm is parsing it as yaml)
After correcting it, it solved my issue
Upvotes: 4
Reputation: 953
I think the template
command with --debug
is the expected debug route for this kind of issue, e.g:
helm template ./yourchart/ -f your-overrides.yaml -n your-ns --debug
Here helm will do its best to try and produce the YAML, and allow you to inspect and see whether you can see errors more clearly.
Upvotes: 8
Reputation: 6952
In my case, I had written
name: { { template "cp-kafka.fullname" . } }-jaas-configmap
due to that giving error.
Right would be
name: {{ template "cp-kafka.fullname" . }}-jaas-configmap
The difference is space between curly brackets.
Upvotes: 6
Reputation: 1729
One way to debug this problem is to do a dry-run and render the template to see what is causing the issue on the offending line.
helm install [Chart] [flags] --dry-run --debug
This would allow you to see which keys are not indented well as this issue is sometimes caused by the wrong indentation.
Upvotes: 1
Reputation: 5149
I found the reason why it is not working. First of all, it is allowed to have comma-separated values but the problematic part was the quotations.
This is the wrong syntax:
value: {{ .Values.SCT_PUB_PORT1 | quote }}, {{ .Values.SCT_PUB_PORT2 | quote }}
And this is the correct one:
value: {{ .Values.SCT_PUB_PORT1 }}, {{ .Values.SCT_PUB_PORT2 }}
Upvotes: 11