0

Following is my configmap content stores in a file called configmap.yaml:


    apiVersion: v1
    data:
      key1: val1
      key2: val2
      key3: val3
    kind: ConfigMap
    metadata:
      creationTimestamp: null
      name: job-inputs
      namespace: qa

And Following is my content of the kustomization.yaml that is present in the same folder where my configmap sits

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- configmap.yaml

However, I want to change the values of my data.keys in the config map using kustomize edit cli command.

I did not find the right documentation which could help me. First of all is this possible through kustomize, if so how?

1 Answers1

0

You cannot change the original file with kustomize CLI.

What you can do is write a configmap patch in the kustomization.yaml file with something like this:


configMapGenerator:
- name: job-inputs
  behavior: merge
  literals:
  - key1=newval1

ConfigMap values from bases may be overridden by adding another generator for the ConfigMap in the overlay and specifying the behavior field. behavior may be one of:

  • create (default value): used to create a new ConfigMap. A name conflict error will be thrown if a ConfigMap with the same name and namespace already exists.
  • replace: replace an existing ConfigMap from the base.
  • merge: add or update the values in an existing ConfigMap from the base.

Documentation: https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/configmapgenerator/

And if you need to, this configmap patch can (probably) be generated with the CLI using kustomize create configmap ....

Documentation: https://kubectl.docs.kubernetes.io/references/kubectl/create/configmap/

Gaël J
  • 11,274
  • 4
  • 17
  • 32