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 MutatingWebhookConfigurations.
cfg*webhookConfig.ConfigThe webhook configuration object containing settings and parameters for the webhook.
defaultNamespacestringThe default Kubernetes namespace to be used for webhook-related resources.
scopepromutils.ScopeThe Prometheus metrics scope for recording and exposing metrics related to the webhook's operation.
mgrmanager.ManagerThe controller-runtime manager responsible for managing controllers and webhooks within the Kubernetes cluster.

Returns

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