Skip to content

✨ Disable the webhook server by setting the port to -1 - #3481

Merged
kubernetes-prow[bot] merged 2 commits into
kubernetes-sigs:mainfrom
troy0820:troy0820/disable-webhook
Jul 27, 2026
Merged

✨ Disable the webhook server by setting the port to -1#3481
kubernetes-prow[bot] merged 2 commits into
kubernetes-sigs:mainfrom
troy0820:troy0820/disable-webhook

Conversation

@troy0820

@troy0820 troy0820 commented Mar 17, 2026

Copy link
Copy Markdown
Member

Resolves #3456

Currently there is no way to disable the webhook server. If we don't set the option, we get one automatically. If we set the port to -1 it would set it to the default port.

This change adds a DisabledServer that Satisfies the webhook.Server interface and allows the port to be set to -1 to signal the disabling of the webhook server.

/assign @sbueringer

Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 17, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: troy0820
Once this PR has been reviewed and has the lgtm label, please ask for approval from sbueringer. 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

@troy0820

Copy link
Copy Markdown
Member Author

Would we rather set it to something different and leave -1 the default port? Disabling the webhooks should be an option if the user wants to disable.

@sbueringer

Copy link
Copy Markdown
Member

Sorry for the delay. I'll take a look soon

Comment thread pkg/webhook/server.go
// Port is the port number that the server will serve.
// It will be defaulted to 9443 if unspecified.
//
// To disable the webhook server set Port to -1.

@sbueringer sbueringer Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given that 0 is the zero value and we previously used the DefaultPort in that case I guess -1 is our only option.

Unfortunately it's inconsistent with the metrics server (that uses 0 for disabled), but I don't have a better idea

@alvaroaleman is that fine for you as well or do you see an alternative?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am unaware of this history of why we would default to 9443 if the user set anything < 0, which to me seems like the user wants to not serve on 9443 if they are going through the trouble of setting it. The 0 value I agree if they don't set it should be 9443, but anything less than that it seems the user is intentionally trying to set it to serve on a port that wouldn't work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree!

Comment thread pkg/webhook/server.go Outdated
Comment thread pkg/manager/internal.go Outdated
Comment thread pkg/manager/manager.go Outdated
Comment thread pkg/manager/manager_test.go Outdated
@kubernetes-prow kubernetes-prow Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 10, 2026
@troy0820
troy0820 force-pushed the troy0820/disable-webhook branch from 06784a0 to c50cfb1 Compare July 10, 2026 13:59
Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>
@troy0820
troy0820 force-pushed the troy0820/disable-webhook branch from c50cfb1 to 558486c Compare July 10, 2026 14:23
@kubernetes-prow kubernetes-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 10, 2026
@troy0820
troy0820 requested a review from sbueringer July 13, 2026 14:11
@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 15, 2026
@sbueringer

Copy link
Copy Markdown
Member

Thank you!

/lgtm
/assign @alvaroaleman

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 15, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: cf58c270ccdb47bfec55babbf3d77fa136c6d0d5

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, troy0820

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

The pull request process is described 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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 27, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit b8d1378 into kubernetes-sigs:main Jul 27, 2026
16 checks passed
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/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide an easy way to turn off the webhook server

4 participants