SecurityLesson 4 of 6
  1. Authentication and service accounts, not reconciled
  2. RBAC, not reconciled
  3. Pod security: securityContext and Pod Security Admission, not reconciled
  4. Admission control and policy, not reconciled
    1. The request path
    2. Built-in plugins
    3. ValidatingAdmissionPolicy
    4. MutatingAdmissionPolicy
    5. Webhooks
    6. Webhook safety
    7. Policy engines
  5. Image supply chain, not reconciled
  6. Audit logging and runtime security, not reconciled

Admission control and policy

Every write passes mutating and then validating admission after authorization. CEL policies run inside the API server; webhooks call out over TLS and fail closed by default.

  • 30 min
  • 4 objectives
  • 7 scenes

Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.

Authentication says who sent a request and authorization says whether that user may perform the verb on the resource. Neither looks inside the object. An authorized user may still create a pod that runs privileged, pulls from an unknown registry or asks for no resource limits. admission controlThe stage of the API server’s request handling that runs after authorization and may change or reject a write before it is stored. is where the cluster inspects the content of a write and decides whether to change it, accept it or refuse it.

Reconcile, in 7 scenes

The request path

A write travels through the API server in a fixed order:

  1. Authentication turns a certificate, token or OIDC identity into a username and groups.
  2. Authorization checks that user against RBAC and the other authorizers for the verb, resource and namespace.
  3. Mutating admission may change the object: fill defaults, add labels, inject containers.
  4. Schema validation checks that the object, as mutated, is still a valid object of its kind.
  5. Validating admission may only accept or reject. It cannot change anything.
  6. The object is written to etcd.

All mutating admission finishes before any validating admission starts, so validators judge the final object, including every change a mutator made. A request rejected by any plugin is rejected immediately, and the remaining plugins never see it. Admission applies to requests that create, update, patch or delete objects, and to connect requests such as exec, attach and port-forward. It never applies to get, list or watch: reads are governed by authorization alone.

Authorization is the stage some users skip. Members of the system:masters group bypass every RBAC check, and removing RoleBindings or ClusterRoleBindings cannot revoke that access, which is why the RBAC good practices say to keep users out of the group. Admission still runs for them: a system:masters credential can bind any role, but the pods it creates still go through PodSecurity and every policy.

RBAC and PodSecurity both answer with HTTP 403 Forbidden, so read the message to tell them apart. Here the service account ci in shop may create pods but not deployments, and the namespace enforces Pod Security baseline. The manifest it creates is a pod that asks for a privileged container:

apiVersion: v1
kind: Pod
metadata:
  name: debug
  namespace: shop
spec:
  containers:
  - name: shell
    image: busybox:1.37
    command: ["sleep", "3600"]
    securityContext:
      privileged: true
Refused by authorization, then by admission
kubectl create deployment web -n shop --image=nginx:1.31 --as=system:serviceaccount:shop:ci
error: failed to create deployment: deployments.apps is forbidden: User "system:serviceaccount:shop:ci" cannot create resource "deployments" in API group "apps" in the namespace "shop"
kubectl label namespace shop pod-security.kubernetes.io/enforce=baseline
namespace/shop labeled
kubectl create -f debug.yaml --as=system:serviceaccount:shop:ci
Error from server (Forbidden): error when creating "debug.yaml": pods "debug" is forbidden: violates PodSecurity "baseline:latest": privileged (container "shell" must not set securityContext.privileged=true)

The first error names a user, a verb and a resource: authorization refused it, and admission never saw the object. The second names a plugin and a field: the user was allowed to create pods, and admission refused this pod.

A later plugin can reject a request after an earlier one acted on it, so plugins with side effects must reconcile: ResourceQuota counts usage when it admits a request, and a controller recalculates the totals in case the write never landed.

Built-in plugins

Admission plugins are compiled into kube-apiserver. On a self-managed control plane, --enable-admission-plugins adds plugins to the default set and --disable-admission-plugins removes them. Managed control planes do not expose these flags; the provider fixes the list and publishes it per platform version.

In Kubernetes 1.37 the default set is CertificateApproval, CertificateSigning, CertificateSubjectRestriction, DefaultIngressClass, DefaultStorageClass, DefaultTolerationSeconds, LimitRanger, MutatingAdmissionPolicy, MutatingAdmissionWebhook, NamespaceLifecycle, PersistentVolumeClaimResize, PodSecurity, Priority, ResourceQuota, RuntimeClass, ServiceAccount, StorageObjectInUseProtection, TaintNodesByCondition, ValidatingAdmissionPolicy and ValidatingAdmissionWebhook. A few of them shape almost every pod:

  • NamespaceLifecycle (validating) refuses objects in a namespace that does not exist or is terminating, and refuses deletion of default, kube-system and kube-public.
  • LimitRanger (mutating and validating) fills in default requests and limits from a namespace’s LimitRange, then rejects containers outside its bounds.
  • ServiceAccount (mutating and validating) sets serviceAccountName: default when a pod names none and adds the projected kube-api-access volume that carries the token.
  • DefaultTolerationSeconds (mutating) adds 300-second tolerations for the not-ready and unreachable taints.
  • ResourceQuota (validating) counts the request against the namespace’s quotas. It sees the final object, so requests and limits that LimitRanger filled in are charged too.
  • PodSecurity (validating) applies the Pod Security Standards selected by namespace labels. It replaced PodSecurityPolicy, which was removed in Kubernetes 1.25; material that configures PodSecurityPolicy predates that release.

NodeRestriction is not in the default set, but kubeadm enables it, so kind clusters have it: each kubelet may modify only its own Node object and the pods bound to it.

Mutating plugins leave traces on the stored object. Create a pod in a namespace that has a LimitRange and look at what admission added:

What mutating admission wrote into a pod
kubectl run web -n shop --image=nginx:1.31
pod/web created
kubectl get pod web -n shop -o jsonpath='{.metadata.annotations}'
{"kubernetes.io/limit-ranger":"LimitRanger plugin set: cpu, memory request for container web; cpu, memory limit for container web"}
kubectl get pod web -n shop -o jsonpath='{.spec.containers[0].resources}'
{"limits":{"cpu":"500m","memory":"256Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}
kubectl get pod web -n shop -o jsonpath='{.spec.serviceAccountName} {.spec.volumes[0].name}'
default kube-api-access-jvfwk
kubectl get pod web -n shop -o jsonpath='{.spec.tolerations[*].key}'
node.kubernetes.io/not-ready node.kubernetes.io/unreachable

The command asked for none of this. Three built-in plugins wrote it before the pod reached etcd.

Four plugins in the default list are hooks. ValidatingAdmissionPolicy and MutatingAdmissionPolicy evaluate policies stored as API objects; ValidatingAdmissionWebhook and MutatingAdmissionWebhook call HTTPS services. Everything a cluster operator adds goes through one of them.

ValidatingAdmissionPolicy

A ValidatingAdmissionPolicyAn API object holding CEL expressions that the API server evaluates in-process against matching requests; GA in Kubernetes 1.30. moves validation into the API server: no service to run, no network hop, no certificate to rotate. It went alpha in Kubernetes 1.26, beta in 1.28 and GA in 1.30, at admissionregistration.k8s.io/v1.

The design splits the rule from its application. The policy says what to check; a ValidatingAdmissionPolicyBinding says where it applies and what a failure does. Neither has any effect alone.

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: replica-limit.example.com
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
    - apiGroups: ["apps"]
      apiVersions: ["v1"]
      operations: ["CREATE", "UPDATE"]
      resources: ["deployments"]
  validations:
  - expression: "object.spec.replicas <= 5"
    messageExpression: "'replicas must be 5 or fewer, got ' + string(object.spec.replicas)"
    reason: Invalid
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: replica-limit-test.example.com
spec:
  policyName: replica-limit.example.com
  validationActions: [Deny]
  matchResources:
    namespaceSelector:
      matchLabels:
        environment: test

Each expression is CELCommon Expression Language: a small, side-effect-free expression language that Kubernetes evaluates with cost limits, used in admission policies and CRD validation. and must return true for the request to pass. It can read object (the incoming object, null on DELETE), oldObject (null on CREATE), request (user, operation, namespace), namespaceObject, params, variables and authorizer, which can ask RBAC questions about the requesting user. A denial names the policy, the binding and the message:

error: failed to create deployment: deployments.apps "web" is forbidden: ValidatingAdmissionPolicy 'replica-limit.example.com' with binding 'replica-limit-test.example.com' denied request: replicas must be 5 or fewer, got 6

validationActions decides what a false result does. Deny rejects the request. Warn returns the failure to the client as an HTTP warning, which kubectl prints. Audit adds it to the request’s audit event. Deny and Warn cannot be combined. Rolling out with [Warn, Audit] shows who would break before the binding switches to [Deny].

failurePolicy is a different thing: it covers errors, not false results. An expression that fails to evaluate, or a binding whose parameter object is missing, is enforced through the binding’s actions when failurePolicy is Fail, the default, and ignored when it is Ignore. To reuse one policy with different values, set paramKind on the policy and paramRef on each binding; paramRef.parameterNotFoundAction is required and decides, Allow or Deny, what happens when the referenced object does not exist. Expressions should test params != null before using it.

The API server type-checks every expression against the schemas of the matched kinds and reports mistakes in the policy’s status.typeChecking, so object.replicas written for object.spec.replicas shows up as an undefined-field warning before any request trips over it.

Some kinds are out of reach. Policies created through the API cannot intercept ValidatingAdmissionPolicies, MutatingAdmissionPolicies or their bindings, which prevents a policy that locks out its own repair. TokenReviews, SubjectAccessReviews and the other authentication and authorization review kinds are exempt from every policy. Kubernetes 1.36 added manifest-based admission configuration, beta and on by default in 1.37: the staticManifestsDir field in the AdmissionConfiguration file points kube-apiserver at policy and webhook manifests on disk. Those policies are enforced from API server startup, keep working while etcd is unavailable, and may intercept the admission objects themselves. Names ending in .static.k8s.io are reserved for them. The API server watches the files, reloads valid changes and keeps the previous configuration when a change is invalid.

MutatingAdmissionPolicy

A MutatingAdmissionPolicy does for mutation what ValidatingAdmissionPolicy does for validation. It went beta in Kubernetes 1.34 and is GA in 1.36 at admissionregistration.k8s.io/v1. Its shape is the same: matchConstraints, matchConditions, a failurePolicy and parameters on the policy, and a MutatingAdmissionPolicyBinding that activates it for selected namespaces.

Each mutation is a CEL expression that returns either an apply configuration or a list of JSON patches. With patchType: ApplyConfiguration, the expression builds a partial object that the API server merges with server-side apply rules. This policy adds a native sidecar to pods in namespaces labelled mesh: enabled:

apiVersion: admissionregistration.k8s.io/v1
kind: MutatingAdmissionPolicy
metadata:
  name: sidecar-policy.example.com
spec:
  matchConstraints:
    resourceRules:
    - apiGroups: [""]
      apiVersions: ["v1"]
      operations: ["CREATE"]
      resources: ["pods"]
  matchConditions:
  - name: no-proxy-yet
    expression: '!has(object.spec.initContainers) || !object.spec.initContainers.exists(c, c.name == "mesh-proxy")'
  failurePolicy: Fail
  reinvocationPolicy: IfNeeded
  mutations:
  - patchType: ApplyConfiguration
    applyConfiguration:
      expression: >
        Object{
          spec: Object.spec{
            initContainers: [
              Object.spec.initContainers{
                name: "mesh-proxy",
                image: "mesh/proxy:v1.0.0",
                args: ["proxy", "sidecar"],
                restartPolicy: "Always"
              }
            ]
          }
        }
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingAdmissionPolicyBinding
metadata:
  name: sidecar-binding.example.com
spec:
  policyName: sidecar-policy.example.com
  matchResources:
    namespaceSelector:
      matchLabels:
        mesh: enabled

The match condition makes the mutation idempotent: a pod that already has the proxy is skipped, so a second pass adds nothing. Apply configurations merge into lists keyed by name, such as initContainers, but cannot change atomic structs, maps or lists; for those, use patchType: JSONPatch and return JSONPatch{op: "add", path: ..., value: ...} values. JSON Patch paths escape / in a key as ~1 and ~ as ~0, and jsonpatch.escapeKey("example.com/team") does it for you.

A mutating policy runs in-process, so there is no service to be down. What can go wrong is a CEL error, handled by its failurePolicy, or a mutation that leaves an object later validation rejects.

Webhooks

Admission webhooks predate CEL policies and remain the way to run logic that CEL cannot express: calls to external systems, signature checks, anything that needs state. A admission webhookAn HTTPS service the API server calls during admission with an AdmissionReview; registered through a MutatingWebhookConfiguration or ValidatingWebhookConfiguration. receives an admission.k8s.io/v1 AdmissionReview containing the request and the object, and answers with the request’s uid, allowed, an optional status message and, for mutating webhooks, a base64-encoded JSON Patch. Either kind may return warnings, which kubectl prints.

The configuration names what to send and where:

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: image-policy.example.com
  annotations:
    cert-manager.io/inject-ca-from: policy-system/image-policy-serving
webhooks:
- name: image-policy.example.com
  admissionReviewVersions: ["v1"]
  sideEffects: None
  failurePolicy: Fail
  timeoutSeconds: 5
  clientConfig:
    service:
      namespace: policy-system
      name: image-policy
      path: /validate
  rules:
  - apiGroups: [""]
    apiVersions: ["v1"]
    operations: ["CREATE", "UPDATE"]
    resources: ["pods"]
    scope: Namespaced
  namespaceSelector:
    matchExpressions:
    - key: kubernetes.io/metadata.name
      operator: NotIn
      values: ["kube-system", "kube-node-lease", "policy-system"]
  matchConditions:
  - name: exclude-kubelet-requests
    expression: '!("system:nodes" in request.userInfo.groups)'

The API server dials the Service on port 443 unless port says otherwise, and trusts the serving certificate only if caBundle holds the CA that signed it and the certificate is valid for image-policy.policy-system.svc. The annotation asks cert-manager’s CA injector to fill caBundle. sideEffects is required, and admissionregistration.k8s.io/v1 accepts only None or NoneOnDryRun: a webhook that has side effects must skip them when the request is a dry run.

Ordering differs by kind. Matching mutating webhooks are called one after another, but their order is not a contract, so each must be idempotent and must not assume it runs last. With reinvocationPolicy: IfNeeded, a webhook may be called again in the same request if other plugins changed the object after its first call; Kubernetes does not inspect what the webhook does, does not promise exactly one extra call, and may reorder such webhooks. The default is Never. Matching validating webhooks are called in parallel, and any one rejection fails the request.

A JSON Patch add needs its parent to exist. Adding /metadata/labels/team to a pod without labels fails; add /metadata/labels as an object first. Appending to /spec/containers/0/env/- fails when env is absent. A label key such as example.com/team becomes /metadata/labels/example.com~1team.

Sidecar injectors are the familiar mutating webhooks. Istio’s sidecar mode injects istio-proxy this way; with native sidecars, stable in Kubernetes 1.33, Istio’s 1.27 change notes make it an init container with restartPolicy: Always by default. Istio’s ambient mode, GA since Istio 1.24, injects nothing: a ztunnel per node and optional waypoint proxies carry the traffic.

Webhook safety

A webhook sits in the write path of everything it matches, and its defaults fail closed. failurePolicy defaults to Fail, which applies to connection errors, timeouts, non-2xx responses and responses that cannot be decoded. An explicit allowed: false always denies, whatever the policy. timeoutSeconds defaults to 10 and must be between 1 and 30. A webhook that is down or slow therefore blocks every matching write, and the client sees failed calling webhook "image-policy.example.com" followed by the transport error. A webhook that answers and refuses produces admission webhook "image-policy.example.com" denied the request: and its message.

The rules that keep a webhook from becoming an outage:

  • Exclude system namespaces by name. Select on kubernetes.io/metadata.name, which the control plane sets on every namespace and which no user can change. A custom label such as environment excludes nothing that lacks it.
  • Leave leases and virtual resources alone. Each kubelet renews its Lease in kube-node-lease every 10 seconds by default, and a webhook on Leases turns its own latency into node health trouble. From Kubernetes 1.37, webhooks skip TokenReviews, SubjectAccessReviews and the other virtual authentication and authorization kinds by default, a beta change; interception of them is deprecated.
  • Use objectSelector only for opt-in webhooks. Users set their own labels, so a label that excludes an object from a security webhook is a label anyone can add.
  • Narrow with matchConditions. Up to 64 CEL conditions decide whether to call the webhook at all; filtering in the API server is cheaper than a round trip that answers allowed.
  • Keep the timeout short and the handler faster. A webhook that calls another service must check the error before reading the response, close the response body, and set its client timeout below its own timeoutSeconds so it can answer before the API server gives up.
  • Fail open where you can, then validate. The good-practices guide suggests failurePolicy Ignore for mutating webhooks, paired with a validating check of the final state.

Kubernetes recommends a CEL policy over a webhook wherever CEL can express the rule. List what a cluster calls with kubectl get validatingwebhookconfigurations and kubectl get mutatingwebhookconfigurations; each entry is a dependency of every write it matches.

Policy engines

Kyverno and Gatekeeper run as admission webhooks and add what the built-in hooks lack: policy libraries, background scans of existing objects, reports, exceptions and, in Kyverno’s case, image verification and resource generation.

Kyverno’s policies are CEL-based kinds in policies.kyverno.io/v1: ValidatingPolicy, MutatingPolicy, GeneratingPolicy and ImageValidatingPolicy. A ValidatingPolicy is a superset of ValidatingAdmissionPolicy, with validationActions in the same place:

apiVersion: policies.kyverno.io/v1
kind: ValidatingPolicy
metadata:
  name: require-team-label
spec:
  validationActions: [Deny]
  matchConstraints:
    resourceRules:
    - apiGroups: [""]
      apiVersions: ["v1"]
      operations: ["CREATE", "UPDATE"]
      resources: ["pods"]
  validations:
  - message: "label 'team' is required"
    expression: "'team' in object.metadata.?labels.orValue({})"

Kyverno material written for 1.12 and earlier uses kyverno.io/v1 ClusterPolicy with validationFailureAction: enforce. Kyverno 1.13 moved that setting to each rule’s failureAction, spelled Audit or Enforce, and match.any or match.all replaced a bare match.resources; ValidatingPolicy became stable in Kyverno 1.17; and Kyverno 1.20.0, released on 2026-11-12, blocks creating or updating the legacy ClusterPolicy and Policy kinds and no longer enforces them. Write policies as ValidatingPolicy.

Gatekeeper packages Rego from Open Policy Agent. A ConstraintTemplate in templates.gatekeeper.sh/v1 defines a constraint kind and its Rego; constraints of that kind apply it with parameters. Gatekeeper 3.23.1 evaluates templates as Rego v0, violation[{"msg": msg}] { ... }, by default; Rego v1, violation contains {"msg": msg} if { ... }, is opt-in from Gatekeeper 3.19 through a code entry with engine: Rego and version: "v1".

Whichever engine you choose, it is a webhook, and every rule in the previous section applies to it.

Enforce a replica limit and find its gap

  1. kubectl --context kind-kx create namespace vap-demo
  2. kubectl --context kind-kx label namespace vap-demo environment=test
  3. kubectl --context kind-kx apply -f replica-limit.yaml
  4. kubectl --context kind-kx get validatingadmissionpolicy replica-limit.example.com -o jsonpath='{.status.typeChecking}'
  5. kubectl --context kind-kx -n vap-demo create deployment web --image=nginx:1.31 --replicas=6
  6. kubectl --context kind-kx -n vap-demo create deployment web --image=nginx:1.31 --replicas=3
  7. kubectl --context kind-kx -n vap-demo scale deployment web --replicas=8
  8. kubectl --context kind-kx get mutatingwebhookconfigurations,validatingwebhookconfigurations
  9. kubectl --context kind-kx delete -f replica-limit.yaml
  10. kubectl --context kind-kx delete namespace vap-demo

For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. Save the policy and binding from the ValidatingAdmissionPolicy section as replica-limit.yaml first. The 6-replica create is denied with the replicas message, the 3-replica create succeeds, and the scale to 8 succeeds too, because the policy does not match deployments/scale. Add deployments/scale to the resources, apply again and scale to 9 to see it denied.

Actual state

Check your understanding

5 checks

Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.

  1. Check 1 of 5

    A mutating webhook injects a debugging sidecar with securityContext.privileged: true into every pod in shop, which enforces Pod Security baseline. What happens when a Deployment in shop creates a pod?

  2. Check 2 of 5

    A ValidatingWebhookConfiguration for pods sets no failurePolicy and no timeoutSeconds. The webhook's only pod is crash-looping. What does a kubectl run in a matched namespace do?

  3. Check 3 of 5

    A ValidatingAdmissionPolicyBinding sets validationActions: [Warn, Audit]. A Deployment violates the policy. What happens?

  4. Check 4 of 5

    Which namespaceSelector stops a webhook from intercepting requests in kube-system?

  5. Check 5 of 5

Lesson not yet reconciled

Desired: 4 objectives, 0 metReconciled: 4 of 4 objectives met

  • Place mutating and validating admission in the request path and say what each may change. (not yet met)
  • Write a ValidatingAdmissionPolicy in CEL and bind it to namespaces. (not yet met)
  • Mutate objects with a MutatingAdmissionPolicy, GA in Kubernetes 1.36, instead of a webhook. (not yet met)
  • Configure webhooks safely, with failurePolicy (default Fail), timeouts and exclusions for system namespaces. (not yet met)

Pass every check above to reconcile this lesson.

Every check has passed, so the desired state is met. First-try accuracy: 0 of 5. This lesson's review cards are in your queue.

Practice

Put this lesson to work on the simulated cluster. Everything runs in your browser, with nothing to install.

Changed since the notes

This lesson draws on an earlier set of study notes. Where the documentation contradicts a claim in them, qualifies it or has moved past it, the claim is listed here with the corrected statement and the source it was checked against.

Show 16 corrections
  1. Stale, true once, no longerSecurity Best Practices

    The notes saidEKS encrypts etcd by default, but you can add envelope encryption with your own KMS key at create-cluster

    CorrectedOn Kubernetes 1.28 and later, EKS envelope-encrypts all Kubernetes API data with KMS v2 and an AWS-owned key by default. You can use your own KMS key at creation or associate one with an existing cluster (aws eks associate-encryption-config); once enabled it can't be disabled.

    Sourcedocs.aws.amazon.com/eks/latest/userguide/envelope-encryption.html%20;%20https://docs.aws.amazon.com/eks/latest/userguide/enable-kms.html

  2. Stale, true once, no longerSecurity Best Practices

    The notes saidKyverno validationFailureAction: enforce with match.resources.kinds; lowercase 'enforce' is the deprecated spelling (grouped)

    CorrectedKyverno 1.13 deprecated spec.validationFailureAction in favour of per-rule validate.failureAction, with the capitalised values Audit or Enforce. Kyverno later replaced ClusterPolicy with CEL-based policies.kyverno.io/v1 types such as ValidatingPolicy (stable in 1.17), and Kyverno 1.20.0 (Nov 12, 2026) blocks creating or updating legacy ClusterPolicy/Policy resources. Write the example as a ValidatingPolicy.

    Sourcekyverno.io/docs/guides/migration-to-cel/%20;%20https://github.com/kyverno/kyverno/releases/tag/v1.20.0

  3. Nuance, true with conditionsSecurity Best Practices

    The notes saidaws guardduty create-detector --features EKS_AUDIT_LOGS

    CorrectedEKS_AUDIT_LOGS is still a valid feature name, but the CLI form is --features Name=EKS_AUDIT_LOGS,Status=ENABLED. For runtime threat detection use RUNTIME_MONITORING, which covers EKS, ECS on Fargate and EC2; it can't be enabled together with the older EKS_RUNTIME_MONITORING.

    Sourcedocs.aws.amazon.com/guardduty/latest/APIReference/API_DetectorFeatureConfiguration.html

  4. Nuance, true with conditionsSecurity Best Practices

    The notes saidAdmission controllers via OPA Gatekeeper and Kyverno

    CorrectedKubernetes has built-in CEL admission policies that need no webhook: ValidatingAdmissionPolicy (GA in 1.30) and MutatingAdmissionPolicy (GA in 1.36). Gatekeeper and Kyverno remain options.

    Sourcekubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/%20;%20https://kubernetes.io/docs/reference/access-authn-authz/mutating-admission-policy

  5. Nuance, true with conditionsSecurity Best Practices

    The notes saidMaps an IAM AdminRole to system:masters without warning that this group bypasses RBAC

    CorrectedConfirmed. Members of system:masters bypass all RBAC checks, and removing RoleBindings or ClusterRoleBindings can't revoke that access; the Kubernetes RBAC good practices say to avoid adding users to it. On EKS, grant admin through an access entry with AmazonEKSClusterAdminPolicy.

    Sourcekubernetes.io/docs/concepts/security/rbac-good-practices

  6. Stale, true once, no longerAdmission Controllers and Webhooks

    The notes saidKyverno ClusterPolicy with validationFailureAction: enforce and match.resources.kinds.

    CorrectedSpec-level validationFailureAction is deprecated (since Kyverno 1.13) in favor of per-rule spec.rules[].validate.failureAction; lowercase enforce/audit are deprecated for Enforce/Audit; match.any[]/match.all[] replace bare match.resources. kyverno.io/v1 ClusterPolicy itself is deprecated in favor of CEL-based policies.kyverno.io kinds (ValidatingPolicy with validationActions, MutatingPolicy, GeneratingPolicy, ImageValidatingPolicy). Current Kyverno: v1.20.0.

    Sourcekyverno.io/docs/guides/migration-to-cel/%20;%20https://kyverno.io/docs/policy-types/cluster-policy/policy-settings

  7. Nuance, true with conditionsAdmission Controllers and Webhooks

    The notes saidGatekeeper ConstraintTemplate with Rego violation[{"msg": msg}] {…}.

    CorrectedThe v0 syntax still works because Gatekeeper (v3.23.1) defaults to Rego v0 even though OPA 1.0 made Rego v1 the OPA default. Rego v1 is opt-in since Gatekeeper 3.19 via targets[].code[] with engine Rego and version: "v1", written as violation contains {"msg": msg} if { … } without import rego.v1. Use templates.gatekeeper.sh/v1.

    Sourceopen-policy-agent.github.io/gatekeeper/website/docs/constrainttemplates

  8. Nuance, true with conditionsAdmission Controllers and Webhooks

    The notes saidWebhooks have a timeout (default 10 seconds).

    CorrectedCorrect: timeoutSeconds defaults to 10 and must be 1-30. Also state that failurePolicy defaults to Fail in admissionregistration.k8s.io/v1, so a slow or down webhook blocks matching requests.

    Sourcekubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers

  9. Nuance, true with conditionsAdmission Controllers and Webhooks

    The notes saidIstio uses webhook injection to add Envoy proxies to spec.containers.

    CorrectedSidecar mode still injects via a mutating webhook, but with Kubernetes native sidecars (stable in 1.33: initContainers with restartPolicy: Always) Istio injects istio-proxy as a native sidecar init container (ENABLE_NATIVE_SIDECARS defaults to true from Istio 1.27 per the 1.27 change notes, not confirmed on the stable site here). Ambient mode (GA in Istio 1.24) injects no sidecar at all: ztunnel per node plus optional waypoint proxies.

    Sourcekubernetes.io/docs/concepts/workloads/pods/sidecar-containers/%20;%20https://istio.io/latest/blog/2024/ambient-reaches-ga/%20;%20https://preliminary.istio.io/latest/news/releases/1.27.x/announcing-1.27/change-notes

  10. Stale, true once, no longerAdmission Controllers and Webhooks

    The notes saidRather than building custom webhooks, policy engines provide frameworks.

    CorrectedKubernetes has built-in CEL admission policies: ValidatingAdmissionPolicy (GA 1.30) and MutatingAdmissionPolicy (alpha 1.32, beta 1.34, GA 1.36 at admissionregistration.k8s.io/v1). They run in-process with no webhook to operate; Kubernetes 1.36 also adds manifest-based admission policies loaded from files. Policy engines remain useful for reporting, generation and image verification.

    Sourcekubernetes.io/docs/reference/access-authn-authz/mutating-admission-policy/%20;%20https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy

  11. Nuance, true with conditionsAdmission Controllers and Webhooks

    The notes saidCheck --enable-admission-plugins in API server configuration.

    CorrectedValid for self-managed clusters only. On EKS the API server flags are not configurable; the enabled admission controllers are listed per platform version (for 1.37: NodeRestriction, ExtendedResourceToleration, NamespaceLifecycle, LimitRanger, ServiceAccount, TaintNodesByCondition, PodSecurity, Priority, DefaultTolerationSeconds, DefaultStorageClass, StorageObjectInUseProtection, PersistentVolumeClaimResize, RuntimeClass, CertificateApproval, CertificateSigning, CertificateSubjectRestriction, DefaultIngressClass, MutatingAdmissionWebhook, ValidatingAdmissionWebhook, ResourceQuota).

    Sourcedocs.aws.amazon.com/eks/latest/userguide/platform-versions.html

  12. Wrong, not trueAdmission Controllers and Webhooks

    The notes saidMultiple webhooks 'run in order (sorted by name for each type)'.

    CorrectedMatching validating webhooks are called in parallel and any rejection fails the request. Mutating webhooks are called in sequence, but their order is not a contract: do not rely on it, make mutating webhooks idempotent, and use reinvocationPolicy: IfNeeded if you must observe later mutations.

    Sourcekubernetes.io/docs/reference/access-authn-authz/admission-controllers/%20;%20https://kubernetes.io/docs/concepts/cluster-administration/admission-webhooks-good-practices

  13. Wrong, not trueAdmission Controllers and Webhooks

    The notes saidnamespaceSelector example uses key: environment NotIn [kube-system].

    CorrectedThat selects on a custom 'environment' label and does not exclude kube-system. Exclude by name with matchExpressions: [{key: kubernetes.io/metadata.name, operator: NotIn, values: [kube-system]}] (the control plane sets that immutable label on every namespace).

    Sourcekubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/%20;%20https://kubernetes.io/docs/concepts/services-networking/network-policies

  14. Wrong, not trueAdmission Controllers and Webhooks

    The notes saidJSONPatch 'add /metadata/labels/injected' and 'add /spec/containers/0/env/-'.

    CorrectedRFC 6902 'add' requires the parent to exist: adding /metadata/labels/injected fails when labels is absent (add /metadata/labels as an object first) and /spec/containers/0/env/- fails when env is absent. Keys containing '/' must be escaped as '~1' (and '~' as '~0') per RFC 6901, e.g. /metadata/labels/example.com~1injected.

    Sourcerfc-editor.org/rfc/rfc6902%20;%20https://www.rfc-editor.org/rfc/rfc6901

  15. Wrong, not trueAdmission Controllers and Webhooks

    The notes saidExternal-validation Go snippet reads response.StatusCode without checking err and never closes the body.

    CorrectedOn error the Response must be ignored (it is nil except on CheckRedirect failures), so check err first; on success the caller must close resp.Body (defer resp.Body.Close()). Also set a client timeout below the webhook timeoutSeconds.

    Sourcepkg.go.dev/net/http#Client.Do

  16. Wrong, not trueAdmission Controllers and Webhooks

    The notes saidreinvocationPolicy IfNeeded re-runs 'if changes might affect this webhook's logic'.

    CorrectedWith IfNeeded the webhook may be called again in the same admission evaluation if the object was modified by other admission plugins after its initial call. Kubernetes does not inspect the webhook's logic, does not guarantee exactly one extra call, and may reorder such webhooks; the default is Never.

    Sourcekubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers

Every correction across the guide, by note and topic.

Sources

Checked against kubernetes.io and AWS documentation for Kubernetes 1.37 on .

  1. kubernetes.io/docs/reference/access-authn-authz/admission-controllers
  2. kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy
  3. kubernetes.io/docs/reference/access-authn-authz/mutating-admission-policy
  4. kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers
  5. kubernetes.io/docs/concepts/cluster-administration/admission-webhooks-good-practices
  6. kubernetes.io/docs/concepts/security/rbac-good-practices
  7. kubernetes.io/blog/2026/08/26/kubernetes-v1-37-release
  8. kyverno.io/docs/policy-types/validating-policy
  9. github.com/kyverno/kyverno/releases/tag/v1.20.0
  10. open-policy-agent.github.io/gatekeeper/website/docs/howto
  11. istio.io/latest/docs/ambient/overview
  12. cert-manager.io/docs/concepts/ca-injector

Admission control and policy

↓ ↑ step, 1 to 7 scene, Esc leave

kind cluster kxLast command: Nothing run yet