Skip to main content

Setup

Initializes the webhook by generating certificates, registering the MutatingWebhookConfiguration, and registering the HTTP handler. This function is called before mgr.Start() to ensure the webhook server is ready to receive requests.

def Setup(
ctx: context.Context,
kubeClient: kubernetes.Interface,
cfg: *webhookConfig.Config,
defaultNamespace: string,
scope: promutils.Scope,
mgr: manager.Manager
) - > error

Initializes the webhook by generating certificates, registering the MutatingWebhookConfiguration, and registering the HTTP handler. This function is called before mgr.Start() to ensure the webhook server is ready to receive requests.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for controlling cancellation and timeouts.
kubeClientkubernetes.InterfaceThe Kubernetes client interface used to interact with the Kubernetes API, specifically for managing certificates and MutatingWebhookConfiguration.
cfg*webhookConfig.ConfigThe webhook configuration object containing settings and parameters for the webhook.
defaultNamespacestringThe default Kubernetes namespace to be used for webhook resources.
scopepromutils.ScopeThe Prometheus metrics scope for reporting metrics related to the webhook's operation.
mgrmanager.ManagerThe controller-runtime manager instance, used to get the scheme and register the webhook handler.

Returns

TypeDescription
errorAn error if any step of the webhook setup fails.