What is the difference between mutating and validating admission webhooks?
IntermediateConceptKubernetes Security
Answer
Mutating webhooks change the object (inject sidecars, add default labels, set runAsNonRoot). Validating webhooks only accept or reject. Mutating runs first, then validating, so validators see the final object.
Security-relevant settings on the webhook configuration:
failurePolicy: Failfor security policy (fail closed),Ignoreonly for non-critical mutation.namespaceSelectorto excludekube-systemso a broken webhook cannot block the control plane.timeoutSecondsshort, because webhook latency adds to every API call.
A webhook outage with Fail can block deployments cluster-wide, so we run webhooks with multiple replicas and PDBs.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate