-
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
Unable to disable commonLabels injection using transformer config: Error: conflicting fieldspecs
#817
Comments
Since
you can't disable adding the commonLabel to this path by changing it to Skipping certain paths in transformers is not supported yet, but is a reasonable requirement. Any thoughts or ideas on this would be really appreciated. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Has there been any additional thoughts on this one? As it stands there doesn't appear to be any way of overriding defaults specified in
There are many situations in which this behavior is undesirable (e.g. commonLabels are entirely incompatible with headless services where the endpoints are explicitly created). Perhaps a mechanism for completely disabling the default configurations would be appropriate? I may be in the minority but, on first glance, this is how I expected these transformer configurations to function. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Have a look here for the kustomize 3.2 out of the box solution. I personnaly find that it is unmaintainable because you have to copy/paste the transformer.yaml in base/staging and production in order to change the labels you want to apply. If you use this PR Skip kustomize transformers for paths you will see that you will achieve the same result. But when you start to have base, staging, production....you will only have to put the commonlabels.yaml in one place. Your issue has been reproduced here. This issue keeps coming up ( see #1567), and also it is not perfect and kind of difficult to use, kustomize 3.2.0 fixes your issue. /cc @monopole @Liujingfang1 @septh-nr @richardmarshall @ian-howell |
@jbrette While I also have concerns about the maintainability of configuring internal plugins in this way, copying the transformer.yaml file around for bases and overlays isn't necessary. Since the Using the transformer.yaml from your 3.2 example it could be moved into a new directory labeltransformer/kustomization.yaml apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- transformer.yaml base/kustomization.yaml
overlay/kustomization.yaml
I still think we can improve the user experience for this, but at least using this model the config for the transformer can be stored in one place and there wouldn't be the challenges around keeping multiple copies in sync. |
@richardmarshall It flat out does not work. This is what I had difficulties getting the team to understand since we started the discussion.
|
@jbrette It actually does work, at least the pattern of what I was trying to convey works, validated that it does before providing that example idea 😄 The transformer and generator configs are loaded using a completely independent accumulator from the one that is used for resources. Since it is scoped only to a single kustomization file including the same generator/transformer in various places doesn't run into the same issues as the accumulator used for the resources field. For the other concern regarding wanting to tweak portions of the transformer config for various overlays (like the environment label example). While I think it's a bit mind bending you can leverage all the normal kustomization behavior for a transformer config that is defined as a kustomization directory. Can create an overlay for the transformer config which patches it to include additional fieldSpecs for example or add more labels to the set. Pushed the test example I put together to validate this here: https://github.com/richardmarshall/kustomize-examples/tree/master/issue_817 |
Common labels sets a ton of labels by default [1] that are additive and can't be disabled [2]. This PR switches to using the labels field [3] to disable labelling selectors an only label metadata and template/metadata fields. This field is fairly new and isn't documented in the kustomize docs yet, but seems to be the recommended solution moving forward [4] (also docs appear to be incoming). [1] https://github.com/kubernetes-sigs/kustomize/blob/f61b075d3bd670b7bcd5d58ce13e88a6f25977f2/api/konfig/builtinpluginconsts/commonlabels.go [2] kubernetes-sigs/kustomize#817 [3] https://github.com/kubernetes-sigs/kustomize/blob/10026758d314920e8fa3c9c526525d8577d39617/api/types/labels.go [4] kubernetes-sigs/kustomize#1009
Common labels sets a ton of labels by default [1] that are additive and can't be disabled [2]. This PR switches to using the labels field [3] to disable labelling selectors an only label metadata and template/metadata fields. This field is fairly new and isn't documented in the kustomize docs yet, but seems to be the recommended solution moving forward [4] (also docs appear to be incoming). [1] https://github.com/kubernetes-sigs/kustomize/blob/f61b075d3bd670b7bcd5d58ce13e88a6f25977f2/api/konfig/builtinpluginconsts/commonlabels.go [2] kubernetes-sigs/kustomize#817 [3] https://github.com/kubernetes-sigs/kustomize/blob/10026758d314920e8fa3c9c526525d8577d39617/api/types/labels.go [4] kubernetes-sigs/kustomize#1009
I am trying to to use the commonLabels feature, but without the behavior to inject the label into selectors by using transformer configs. According to the docs, I believe this is described as one of the use cases: "disabling adding commonLabels to fields in some kind of resources"
However, when trying to use transformer configurations to customize the behavior of commonLabels, I get the following error:
Here is a simple kustomization app which reproduces the behavior:
kustomization.yaml
service.yaml
commonlabels.yaml
The text was updated successfully, but these errors were encountered: