Static vs Dynamic webhooks
masterKubewebhook supports two modes of operation depending on how you configure the resource type:
Static Webhooks
Used when a webhook is dedicated to a single resource type.
- For mutating webhooks, configure the resource type using
mutating.WebhookConfig.Obj. - For validating webhooks, configure the resource type using
validating.WebhookConfig.Obj. - This is the recommended approach when working with Custom Resource Definitions (CRDs).
Dynamic Webhooks
Used when a single webhook needs to act on multiple types, unknown types, or generic metadata (like labels and annotations).
- How to use: Do not set the type in the configuration (set it to
nil). - Behavior: If a request arrives for a type not explicitly known by the library, it falls back to using a
runtime.Unstructuredobject. - Use cases: Manipulating
metadata(labels, annotations) across various resources likeDeploymentsandStatefulsetssimultaneously.