Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create ConfigMap from directory using helm

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.

like image 981
Vatan Soni Avatar asked Dec 02 '22 10:12

Vatan Soni


1 Answers

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.

like image 173
helmbert Avatar answered Dec 04 '22 23:12

helmbert