Variables in Kubernetes ConfigMaps

5/30/2019

I'm currently working with some configmaps and I've noticed, that there are some documents in the configmap having redundant values/ referencing the same value e.g.

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
  labels:
    app: my-app
data:
  some_file: |-
     ...
     foo1=bar
     ...
  some_other_file: |-
     ...
     foo2=bar
     ...

Is it somehow possible, to use a variable instead of writing bar two times? This way I wouldn't have to search every config file if bar changes at some point.

-- Urr4
configmap
kubernetes
variables

1 Answer

5/30/2019

No, it's not possible.

If the problems gets worse, you can always start using kustomize or Helm, which allow you to create templates for your Kubernetes manifests, and use variables on those templates.

-- Jose Armesto
Source: StackOverflow