Skip to content

✨ Add namespaceSelector and objectSelector to webhook markers#1339

Open
camilamacedo86 wants to merge 1 commit intokubernetes-sigs:mainfrom
camilamacedo86:namespaceSelector
Open

✨ Add namespaceSelector and objectSelector to webhook markers#1339
camilamacedo86 wants to merge 1 commit intokubernetes-sigs:mainfrom
camilamacedo86:namespaceSelector

Conversation

@camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Feb 15, 2026

Enables filtering webhooks by namespace and object labels to solve the webhook bootstrap problem and support namespace-scoped operators. This markers will allow Kubebuilder abstracts the complexities.

Closes: #553 and #1338

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 15, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: camilamacedo86
Once this PR has been reviewed and has the lgtm label, please assign joelanford for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 15, 2026
@camilamacedo86 camilamacedo86 force-pushed the namespaceSelector branch 2 times, most recently from dad1fdb to 752154a Compare February 15, 2026 08:32
@camilamacedo86
Copy link
Member Author

@sbueringer @JoelSpeed WDYT?

// namespaceSelector=matchLabels~team=platform&matchExpressions~key=tier.operator=NotIn.values=system
//
// Operators: In, NotIn, Exists, DoesNotExist
// Syntax: ~ separates selector type, . separates fields, & combines selectors, | separates values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we just allowed the user to write a JSON object representing a namespace selector, rather than coming up with some complex syntax?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Good idea 👍

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 19, 2026
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 19, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 19, 2026
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 19, 2026
@camilamacedo86 camilamacedo86 force-pushed the namespaceSelector branch 2 times, most recently from c895a1b to a26f666 Compare February 19, 2026 07:59
Enables filtering webhooks by namespace and object labels to solve
the webhook bootstrap problem and support namespace-scoped operators.

Assisted-by: Cursor/Claude
@camilamacedo86
Copy link
Member Author

Hi @JoelSpeed and @sbueringer

Thank you for the help all addressed.

@JoelSpeed
Copy link
Contributor

/lgtm
/assign @sbueringer

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 19, 2026
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

DetailsGit tree hash: 91384a821bc53e82b333bcbae4a51c6aca4e9d84

//
// // +kubebuilder:webhook:...,namespaceSelector=`{"matchLabels":{"webhook-enabled":"true"}}`
// // +kubebuilder:webhook:...,namespaceSelector=`{"matchExpressions":[{"key":"environment","operator":"In","values":["dev","staging","prod"]}]}`
NamespaceSelector string `marker:"namespaceSelector,optional"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead of these two just add a patch marker that contains a strategic merge patch that will be applied over the rest of the webhook so any current and future field can be adjusted that way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

controller-gen feature request: support objectSelector in webhook config generation

5 participants