-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suffix not added to ConfigMap name #5712
Comments
This seems like a similar problem as described here #5223 |
Some more testing. No matter what strategy is used (merge or even replace), when there is a previous |
Seems what I want is a Based on
but I don't see how to add the |
This seems to be more than related #4833 |
I can confirm that the following annotation
makes it work with
|
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 |
Hey there, @stormqueen1990, when it says 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. But it would be great to officially support such an annotation. |
A quick note that the documentation states:
|
Hi @tcurdt, sorry for the delay in getting back to this. I still don't follow why your expected output lists an embedded ConfigMap in a ConfigMap: apiVersion: v1
data:
caddy-configmap.yaml: |
apiVersion: v1
kind: ConfigMap
metadata:
namespace: infra
name: caddy
labels:
app: caddy
data:
Caddyfile: |
{
}
kind: ConfigMap
metadata:
labels:
app: caddy
name: caddy-AB1234
namespace: infra since I don't think that's the goal of
This part is what @ephesused mentioned in the comment prior to this one. Could you give that a try and let me know if it addresses your use case? |
Sorry, map in a map? I have a hard time following that sentence :) Let me try again: I have two maps. One map empty, one map given. I have hash suffixes enabled. For my use case making |
TBH I have no idea what "To take advantage of name suffixing, use configMapGenerator in the base, and the overlay generator will correctly update the suffix based on the new content." is meant to look like. But it sure sounds like overcomplicating things. In the end I just want every ConfigMap to have a content hash suffix to allow for a transparent deployment behaviour. |
@tcurdt, as far as I'm aware, the issue is that the merge behavior honors the original ConfigMap. If the original ConfigMap was generated, then a merge rebuilds the suffix based on the merged content. If the original was a plain ConfigMap, then merge does not add a suffix. So if you want every ConfigMap to have a hashed suffix, then you'll need to define those original ConfigMaps by generators. Here's a simple example of what I was suggesting earlier: kustomization.yaml resources:
- caddy
configMapGenerator:
- name: caddy
namespace: infra
behavior: merge
literals:
- added-key=added-value caddy/kustomization.yaml configMapGenerator:
- name: caddy
namespace: infra
options:
labels:
app: caddy
literals:
- "Caddyfile={\n}"
With these results:
Note that
|
Thanks for example, @ephesused. Can you expand on what you mean by "Note that kustomize updates the suffix based on the newly added entry in the top-level kustomization.yaml"? And while the example might describe the behaviour, I think the behaviour is "not great". For my use case I don't want to have anything in the The overall goal is: If the ConfigMap content changes, also update the deployments (etc) depending on it. |
I follow. I don't think it's worth digging down into my example. It was to show how to leverage current behavior to get the result you want, but that's not the point here. You're looking for a feature that I don't know the "why" that would explain the current behavior, but my guess is what I put in my previous update. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
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 the
ConfigMap
.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
The text was updated successfully, but these errors were encountered: