I have a folder having 3 json files in postman folder. How can I create ConfigMap using helm yaml template.
kubectl create configmap test-config --from-
file=clusterfitusecaseapihelm/data/postman/
Above solution work, but I need this in 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.