Open tcurdt opened 3 weeks ago
This seems like a similar problem as described here https://github.com/kubernetes-sigs/kustomize/issues/5223
Some more testing. No matter what strategy is used (merge or even replace), when there is a previous ConfigMap
exists, the suffix appending does not work.
Seems what I want is a HashTransformer
, the question is what defines NeedHashSuffix
.
Based on BuildAnnotationsGenAddHashSuffix = konfig.ConfigAnnoDomain + "/needsHashSuffix"
I tried to just add an annotation of
annotations:
internal.config.kubernetes.io/needsHashSuffix: true
but I don't see how to add the HashTransformer
yet.
This seems to be more than related https://github.com/kubernetes-sigs/kustomize/issues/4833
I can confirm that the following annotation
internal.config.kubernetes.io/needsHashSuffix: enabled
makes it work with
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- caddy.yaml
generatorOptions:
disableNameSuffixHash: false
Hi there, @tcurdt! Thanks for reporting this issue!
I am a little confused with your expected output. Did you expect the existing ConfigMap to be embedded on a new ConfigMap generated by Kustomize?
/triage needs-information
I am a little confused with your expected output. Did you expect the existing ConfigMap to be embedded on a new ConfigMap generated by Kustomize?
Hey there, @stormqueen1990, when it says behavior: merge
I would have thought it would merge the existing and the generated ConfigMap. In the initial example it would be merging the existing ConfigMap with an empty ConfigMap from the MapGenerator (since no new values are provided).
Since the hashing is enabled I would have thought this also add a hash suffix to the new ConfigMap.
Does that make things clearer?
I still think that's something to fix.
But conceptually, using a transformer with an annotation seems like the cleaner way for my use case.
That said: internal.config.kubernetes.io/needsHashSuffix: enabled
really is not a great annotation to rely on. (given the internal
and the true
vs enabled
problem).
But it would be great to officially support such an annotation.
What happened?
I am trying to use
kustomize
to rewriteConfiMap
names to include a hash suffix. Ideally the suffix is based on the content of theConfigMap
.What did you expect to happen?
Since I am merging an existing
ConfigMap
with an empty one from the generator, I would have expected for the content hash of the final content to be added as a suffix.How can we reproduce it (as minimally and precisely as possible)?
Expected output
Actual output
Kustomize version
v5.4.2
Operating system
MacOS