Basic concepts
Basic concepts
Kubewebhooks embreces simplicity that’s why there are very few components that are required, a webhook server is made up of a server and one or more webhooks.
Webhooks
There are two types of webhooks, Validating
and Mutating
, they are valid Webhook
interface implementation.
Validating webhooks
These webhooks only validate the received object, a Validating webhook is made up of a Validator
interface, this interface only validates an metav1.Object
.
Validating webhooks are with admissionregistration.k8s.io/v1beta1/ValidatingWebhookConfiguration
Kubernetes resource
Validator
can act also as a validator chain, Check validating.Chain
Mutating webhooks
Mutating webhooks are similar to validating webhooks but instead of validating the object it modifies (mutate) them. A Mutating webhook is made up of Mutator
interface.
Mutating webhooks are with admissionregistration.k8s.io/v1beta1/MutatingWebhookConfiguration
Kubernetes resource
Mutator
can act also as a mutator chain, Check mutating.Chain
HTTP Handler
Kubewebhook focuses on the Kubernetes webhooks itself, it doesn’t try to manage the http server, that’s why it will provide a Go http.Handler
and you can set this handler on the http.Server
that you want with the options.
This approach makes gives the user the flexibility to serve the webhook in very customized ways like number of connections, address, paths…
To get a Handler from a previous created Webhook you can use http.HandlerFor
method.
Context
Every webhook receives and passes a context.Context
. In this context is also stored the orignal admissionv1beta1.AdmissionRequest
in case more information is required in a mutator or a validator, like the operation of the webhook (CREATE
, UPDATE
…).