Skip to content

Webhook registration configuration in Kubernetes #1155

@suyanhj

Description

@suyanhj

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions