aisbaa
aisbaa

Reputation: 10633

How to make ConfigMapGenerator based config more intelligent

I like configMapGenerator with suffix hashes because it forces redeployment of pod that are consuming particular config. But the diff output after changing config is just delete and create, which is less than ideal. Is there a way to get more intelligent diff config maps produces by configMapGenerator with suffix hashes?

Edit:

For example if I have kustomization.yaml:

generatorOptions:
  disableNameSuffixHash: false

 configMapGenerator:
  - name: nginx-conf
    files:
    - nginx.conf=config/nginx.conf
  1. Lets assume that for first time kubectl apply -k generates nginx-conf-aaaa config map.

  2. Edit config/nginx.conf.

  3. Lets assume that kubectl apply -k will generate nginx-config-bbbb.

Is there a way to diff nginx-config-aaaa and nginx-config-bbbb before applying changes?

Upvotes: 4

Views: 10205

Answers (1)

GSSwain
GSSwain

Reputation: 6133

You can do something like this

  • Get the current version of the ConfigMap and write it to a file current.yaml

    kubectl get configmap nginx-conf-aaaa -o=yaml > ./current.yaml

  • After making the changes get the new version of the ConfigMap in new.yaml

    kubectl kustomize . > ./new.yaml

  • Then perform a git diff

    git diff --no-index ./current.yaml ./new.yaml

If you are happy with the diff, go ahead and apply the changes.

Upvotes: 1

Related Questions