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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for controlling cancellation and timeouts. |
| kubeClient | kubernetes.Interface | The Kubernetes client interface used to interact with the Kubernetes API, specifically for managing certificates and MutatingWebhookConfigurations. |
| cfg | *webhookConfig.Config | The webhook configuration object containing settings and parameters for the webhook. |
| defaultNamespace | string | The default Kubernetes namespace to be used for webhook-related resources. |
| scope | promutils.Scope | The Prometheus metrics scope for recording and exposing metrics related to the webhook's operation. |
| mgr | manager.Manager | The controller-runtime manager responsible for managing controllers and webhooks within the Kubernetes cluster. |
Returns
| Type | Description |
|---|---|
error | An error if any step of the webhook setup fails. |