I have a folder with 3 json files in a postman
folder. How can I create a ConfigMap using a Helm yaml template?
kubectl create configmap test-config --from-
file=clusterfitusecaseapihelm/data/postman/
The above solution works, but I need this as yaml file as I am using Helm.
Inside a Helm template, you can use the Files.Glob
and AsConfig
helper functions to achieve this:
{{- (.Files.Glob "postman/**.json").AsConfig | nindent 2 }}
Or, to give a full example of a Helm template:
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
{{- (.Files.Glob "postman/**.json").AsConfig | nindent 2 }}
See the documentation (especially the section on "ConfigMap and secrets utility functions") for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With