Skip to content
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

Why set namespace with kustomize for cluster-scoped Mutating|ValidatingWebhookConfiguration? #999

Closed
davidxia opened this issue Jul 2, 2024 · 9 comments

Comments

@davidxia
Copy link

davidxia commented Jul 2, 2024

What happened?

Why does kubebuilder use a namespace kustomization transformer to set a namespace for Mutating|ValidatingWebhookConfiguration if these are cluster-scoped resources? Code here

Isn't this unnecessary?

What did you expect to happen?

IIUC, lines of code above shouldn't exist as they don't do anything?

How can we reproduce it (as minimally and precisely as possible)?

Run kubebuilder create webhook --group batch --version v1 --kind CronJob --defaulting --programmatic-validation as described in Implementing defaulting/validating webhooks.

Expected output

# the following config is for teaching kustomize where to look at when substituting vars.
# It requires kustomize v2.1.0 or newer to work properly.
nameReference:
- kind: Service
  version: v1
  fieldSpecs:
  - kind: MutatingWebhookConfiguration
    group: admissionregistration.k8s.io
    path: webhooks/clientConfig/service/name
  - kind: ValidatingWebhookConfiguration
    group: admissionregistration.k8s.io
    path: webhooks/clientConfig/service/name

varReference:
- path: metadata/annotations

Actual output

# the following config is for teaching kustomize where to look at when substituting vars.
# It requires kustomize v2.1.0 or newer to work properly.
nameReference:
- kind: Service
  version: v1
  fieldSpecs:
  - kind: MutatingWebhookConfiguration
    group: admissionregistration.k8s.io
    path: webhooks/clientConfig/service/name
  - kind: ValidatingWebhookConfiguration
    group: admissionregistration.k8s.io
    path: webhooks/clientConfig/service/name

namespace:
- kind: MutatingWebhookConfiguration
  group: admissionregistration.k8s.io
  path: webhooks/clientConfig/service/namespace
  create: true
- kind: ValidatingWebhookConfiguration
  group: admissionregistration.k8s.io
  path: webhooks/clientConfig/service/namespace
  create: true

varReference:
- path: metadata/annotations

Kustomize version

5.1.0

Operating system

Linux

@davidxia
Copy link
Author

davidxia commented Jul 2, 2024

issue copied from original kubernetes-sigs/kustomize#5484

@sbueringer
Copy link
Member

Isn't this a question for the kubebuilder project/repo?

@davidxia
Copy link
Author

davidxia commented Jul 2, 2024

Isn't this a question for the kubebuilder project/repo?

image

I was following the instructions in https://github.com/kubernetes-sigs/kubebuilder/issues/new?assignees=&labels=kind%2Fbug&projects=&template=bug_report.yaml

@sbueringer
Copy link
Member

I can't speak for the kubebuilder project. But I think it doesn't make sense to discuss code from the kubebuilder repo/project in the controller-tools repo/project. I think they meant if it's related to controller-gen (aka code from controller-tools)

@sbueringer
Copy link
Member

sbueringer commented Jul 2, 2024

The best answer I have is, I don't know why kubebuilder is doing this :)

@davidxia
Copy link
Author

davidxia commented Jul 2, 2024

I duplicated the issue here kubernetes-sigs/kubebuilder#3999

@camilamacedo86
Copy link
Member

@sbueringer

Can you close this one?
It is not related to controller-tools

@sbueringer
Copy link
Member

Sure

/close

@k8s-ci-robot
Copy link
Contributor

@sbueringer: Closing this issue.

In response to this:

Sure

/close

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-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants