Kubernetes - How to define ConfigMap built using a file in a yaml?

前端 未结 3 2124
失恋的感觉
失恋的感觉 2020-12-14 08:49

At present I am creating a configmap from the file config.json by executing:

kubectl create configmap jksconfig --from-file=config.json

I w

3条回答
  •  失恋的感觉
    2020-12-14 09:10

    Soln 01:

    • insert your config.json file content into a template
    • then use this template into your data against config.json
    • then run $ helm install command

    finally,

    {{define "config"}}
    {
        "a": "A",
        "b": {
            "b1": 1
        }
    }
    {{end}}
    
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: jksconfig
      labels:
        chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
        app: "my-app"
        heritage: "{{ .Release.Service }}"
        release: "{{ .Release.Name }}"
    data:
      config.json: {{ (include "config" .) | trim | quote }}
    

提交回复
热议问题