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 MutatingWebhookConfiguration. |
| 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 resources. |
| scope | promutils.Scope | The Prometheus metrics scope for reporting metrics related to the webhook's operation. |
| mgr | manager.Manager | The controller-runtime manager instance, used to get the scheme and register the webhook handler. |
Returns
| Type | Description |
|---|---|
error | An error if any step of the webhook setup fails. |