Multiline values in kustomize environment source file Multiline values in kustomize environment source file kubernetes kubernetes

Multiline values in kustomize environment source file


So it looks like you're creating ConfigMaps using Generators in Kustomize. And in doing so you're attempting to pass the contents of the desired ConfigMap to it directly in your kustomization.yml file.

Better practice would be to instead save the contents of these configuration files to disk and maintain them in the same location as your manifests. Then import them from file into your generators in Kustomize. For example:

configMapGenerator:    - name: ca_contents      files:        - ca.crt

This will produce a ConfigMap with the name ca.crt with the contents of the file.

However, if you wanted, you can do the same thing with the literals operator and use multiline configuration directly in your kustomization.yml. For example:

configMapGenerator:    - name: ca_contents      literals:        - ca.crt=|            CERT_CONTENTS            EACH_NEWLINE_IS_INDENTED_ANOTHER_TIME            You_Can_Add_Additional_literals        - ca.key=>            AND_EVEN            CONCATENATE_THEM            _ONTO_ONE_LINE_WITH_OTHER_OPERATORS_LIKE_>        - cert.crt="You can even mix literals with files in generators."      files:        - cert.key

Let me know if this makes sense. I advise you keep your configuration in files and import them into generators but either solution should work. Feel free to reach out if you need any other help. Kustomize is a really cool project!