Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 943
aisbaa Avatar asked Dec 05 '25 03:12

aisbaa


1 Answers

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.

like image 150
GSSwain Avatar answered Dec 08 '25 11:12

GSSwain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!