Webhooks
Your controllers can serve admission (validating, mutating) and CRD conversion webhooks.
Turning it on
Section titled “Turning it on”Set the controller’s Webhook port (controller-runtime uses 9443). The controller then gets:
Service ctrl-<controller>-webhook, port 443 |
In your control plane’s namespace, forwarded to the webhook port. |
/tmp/k8s-webhook-server/serving-certs/ |
A serving certificate, where controller-runtime looks; renewed automatically. |
Pointing webhooks at it
Section titled “Pointing webhooks at it”Use a service reference and leave caBundle empty: your control plane already trusts the
certificate. You don’t need cert-manager.
clientConfig: service: namespace: acme # your control plane's namespace name: ctrl-guestbook-webhook # ctrl-<controller>-webhook path: /validate-webapp-example-com-v1-guestbookConversion webhooks use the same service in the CRD’s spec.conversion.webhook.clientConfig.
With kubebuilder
Section titled “With kubebuilder”In config/, drop the certmanager directory, the cert-manager.io/inject-ca-from
annotations and the webhook-service, and set the service name and namespace as above.
Limits
Section titled “Limits”- Webhooks may only match your own API groups, not
"",*or groups ending ink8s.ioorkubernetes.io. - With
failurePolicy: Fail, matching requests fail while your controller isn’t running.