The Problem
Have you seen before when a ConfigMap is applied to K8s, the data is messy? When you create a multiline data block like this:
apiVersion: v1 kind: ConfigMap metadata: name: poc data: application.yaml: | foo: bar baz: qux
When it's applied, it shows like that (using kubectl get cm poc -o yaml):
apiVersion: v1 kind: ConfigMap metadata: name: poc data: application.yaml: "foo: bar\n\nbaz: qux \n"
In fact, that issue occurs in any data under certain circumstances, not only in YAML data.
The Root Cause
This isn't a bug per se, but it's how Kubernetes handles whitespace and interpretation of multiline strings in the ConfigMaps.
Main resons for that:
- An empy line.
- An empy space at the end of the line.
- Tabs intendation instead of spaces.
Just ensure you don't have extra spaces in your data. It happens even more in Helm templates because some times some values are empty or missing!
That's it! Happy DevOpsing! :-)