-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
api group missing from label transformer config for core resources #3414
Comments
|
I think @snuggie12 wanted to prevent these labels from being applied to Knative's Service objects. How would LabelTransformer help with that? |
He can explicitly specify |
Would he have to duplicate all the field specs known to the default LabelTransformer, but with the group populated as "core?" |
Unfortunately yes. The problem is the zero value of the |
I was struggling with that lack today, when wishing for negative assertions in Go's regular expression package. For the "target" field in a "patches" entry, I wanted to visit all resources of a particular kind except those whose name matches a certain pattern. I can't express that, so instead I have to try to craft a regular expression that matches all the other names except those I want to omit. I recognize that using label and annotation selectors would be a better way, but it so happens that the target objects in question are neither labeled nor annotated with anything helpful as of now. |
@Shell32-Natsu do you mind elaborating on your solution? If I specify "core" or "" (it's not clear which your suggesting) it will merge with what is in code? Also, if adding something like "core" fixes this then why close? Why not specify the core resources more explicitly? I guess if you could provide exact yaml that'd be great. |
@Shell32-Natsu Can you let me know if I did this correct? This did not work with various combinations and tried multiple versions of kustomize including latest with kyaml enabled and disabled. It does confirm that merging occurs with kustomization.yaml
common-labels-fields.kcfg.yaml
ksvc.yaml (the knative service)
svc.yaml (regular k8s
|
Best I can tell kustomize/api/filters/fieldspec/gvk.go Line 36 in 64ffbcb
|
This is a correct way. BTW, you can also use LabelTransformer as an external plugin with full control of the fieldSpecs. fieldSpecs in the configurations file will be merged with builtin configs while an external plugin config will not. |
@Shell32-Natsu Can both be used at once? If I call LabelTransformer with my special config and commonLabels will commonLabels still try to apply to the knative service? |
@snuggie12 Good question. I suppose they can be used at once but I haven't confirmed it in practice. |
i cant use kustomize with knative.. In the meantime I guess this behavior should be noted in the documentation here? |
I'd say this is something worth considering, knative is a hugely popular framework and this bug is stopping everyone from using kustomize. Any thoughts on reopening? |
To get rid of this issue in knative, I added following patch between my overlays and base. apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../base
# This patch is required to remove the label selectors generated by kustomize for core
# "Service" object which are not supported by the knative "Service" object specification.
# More info available here: https://github.com/kubernetes-sigs/kustomize/issues/3414
patches:
- patch: |-
- op: remove
path: /spec/selector
target:
group: serving.knative.dev
version: v1
kind: Service The above file/directory references "base" directory as base and is referenced in my overlays as base, creating a 3-level kustomize chain. This works because the knative service objects in base are applied the label transformer first and then fed to child which removes the P.S.: In my case the |
Describe the bug
If you use the
commonLabels
transformer and a CRD shares the samekind
andversion
, but not the samegroup
the labels are still applied and a given path might not exist.The big offender is knative. It too uses
Service
forkind
and conflicts with the core resource of the same name since it does not havespec/selector
.Is it possible to add the group here?? I'm not sure if that would be "core" or an empty string (or if the code needs modified to handle an empty string?)
Files that can reproduce the issue
Expected output
Actual output
Kustomize version
v3.8.4 but
master
doesn't have the group specified and I looked in the release notes so I presume it's still not working.Platform
MacOS and Linux
Additional context
The text was updated successfully, but these errors were encountered: