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?
For example if I have kustomization.yaml:
generatorOptions:
disableNameSuffixHash: false
configMapGenerator:
- name: nginx-conf
files:
- nginx.conf=config/nginx.conf
Lets assume that for first time kubectl apply -k generates nginx-conf-aaaa config map.
Edit config/nginx.conf.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With