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

Webhook registration configuration in Kubernetes #1155

Open
suyanhj opened this issue Jan 6, 2025 · 3 comments
Open

Webhook registration configuration in Kubernetes #1155

suyanhj opened this issue Jan 6, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@suyanhj
Copy link

suyanhj commented Jan 6, 2025

Problem

I found that almost all webhooks in the source code are configured by default to be registered to Kubernetes via URL. However, after the service is deployed to the cluster, I believe it should be accessed via the service method instead. I have checked all the official documentation and GitHub examples, but I couldn’t find any related configuration option. So, I would like to ask if there are any plans to add an optional configuration to choose between URL or service for the registration method in the future?

Proposal

Add optional registration configuration for the webhook

Code

def example():
    settings.admission.server = kopf.WebhookServer(addr='0.0.0.0', port=8443, host=conf.listen_host,service=service)

    class WebhookServer(webhacks.WebhookContextManager):
        def __init__(self, *args, **kwargs):
            ...
            self.service = service

        def __call__(self, *args, **kwargs):
            ...
            if self.service:
                client_config = reviews.WebhookClientConfig(service=self.service)
            ...
            client_config = reviews.WebhookClientConfig(url=url)

Additional information

No response

@suyanhj suyanhj added the enhancement New feature or request label Jan 6, 2025
@DeepFlame-JR
Copy link

I really agree with it.

@ran-haim
Copy link

does it actually work for you accessing via url?
for me it does not find the server (even if I specify service.ns.svc in the url).

@suyanhj
Copy link
Author

suyanhj commented Mar 19, 2025

它真的适用于你通过网址访问吗?
对我来说,它找不到服务器(即使我在网址中指定了service.ns.svc)。

What I show is just a proposal, not a complete code. Because the svc method is not supported for the time being, I chose to write a webhook with fastapi. If it is deployed in the cluster, the built-in webhook of kopf is not supported, and can only be used as a development mode modulation in pycharm.

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

No branches or pull requests

3 participants