Skip to content

Conversation

@camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Nov 2, 2025

Users can now set custom paths for webhooks using --defaulting-path and --validation-path flags. Requires controller-runtime v0.21+.

Closes: #4295

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

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

The pull request process is described here

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 2, 2025
@camilamacedo86 camilamacedo86 force-pushed the custom-webhok-path branch 2 times, most recently from 509ce87 to 6f034cb Compare November 2, 2025 17:55
@camilamacedo86
Copy link
Member Author

camilamacedo86 commented Nov 2, 2025

Hey @damsien

Could you please give a hand in this one?
Since you request it I think you will be the best one to help us with reviews :-)
WDYT?

@camilamacedo86 camilamacedo86 force-pushed the custom-webhok-path branch 2 times, most recently from cc396a5 to 7aeaee9 Compare November 2, 2025 20:05
@camilamacedo86
Copy link
Member Author

c/c @sbueringer

Users can now set custom paths for webhooks using --defaulting-path and
--validation-path flags. Requires controller-runtime v0.20+.

Assisted-by: Cursor
@camilamacedo86
Copy link
Member Author

/test pull-kubebuilder-e2e-k8s-1-34-0

@damsien
Copy link
Contributor

damsien commented Nov 3, 2025

Hello @camilamacedo86 , thanks for reaching me!

I tested your implementation and it works well! However, I noticed that you didn't implemented an regex checker for the path. I don't know if it is supposed to not being implemented.

If we need to add the regex validation, I would like to contribute to your PR :)

@camilamacedo86
Copy link
Member Author

Hi @daniem,

Hello @camilamacedo86 , thanks for reaching me!
I tested your implementation and it works well! However, I noticed that you didn't implemented an regex checker for the path. I don't know if it is supposed to not being implemented.

If we need to add the regex validation, I would like to contribute to your PR :)

Thank you for raising and validating this — great work! 🥇

It seems that from the Kubernetes side, any path is accepted, so I’m not entirely sure what kind of validations we could enforce.

Our convention:
/mutate-<group>-<version>-<kind> and /validate-<group>-<version>-<kind>
(with dots in the group replaced by dashes and all lowercase).

That said, since this is already the default behavior, suggesting it might be redundant — so I’m not completely sure it’s worth enforcing.

Given that you’ve verified everything is implemented accurately, I’m happy for us to move forward — great job! 🚀
And please feel free to open any follow-up PRs for improvements you think would be valuable. Your collaboration is very welcome! 🙌

@camilamacedo86 camilamacedo86 added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 4, 2025
@damsien
Copy link
Contributor

damsien commented Nov 4, 2025

To be more precise, I was talking about a regex that checks if the path is a valid path (no weird characters, etc...). The regex validation is already done in controller-runtime: https://github.com/kubernetes-sigs/controller-runtime/blob/67242822fa14d36e8ef7a5f7933022334b11a976/pkg/builder/webhook.go#L374-L383.

Since controller-runtime already implement it, if the user put a wrong path in the kubebuilder command, then he gonna have an error on runtime. So it is not strictly necessary to add the regex validation on the kubebuilder side but still it can be useful :)

@camilamacedo86
Copy link
Member Author

/test pull-kubebuilder-e2e-k8s-1-32-0

1 similar comment
@camilamacedo86
Copy link
Member Author

/test pull-kubebuilder-e2e-k8s-1-32-0

@k8s-ci-robot k8s-ci-robot merged commit 83b229b into kubernetes-sigs:master Nov 4, 2025
38 checks passed
@camilamacedo86 camilamacedo86 deleted the custom-webhok-path branch November 4, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom path for webhooks

3 participants