Advanced Track Do this after finishing Chapters 01-14.

Estimated Time

  • Reading: 30-40 min
  • Lab: 60-90 min
  • Quiz: 15-20 min

Prerequisites

  • Core track (Chapters 01-14) completed.
  • GitOps promotion and observability workflows available.

Source Code References

  • verify-images.example.yaml Members

Sign in to view source code.

What You Will Produce

A go/no-go evidence package: rollout results, remediation notes, and explicit rollback conditions.

Chapter 16: Admission Policy Guardrails

Learning Objectives

By the end of this chapter, you will be able to:

  • Deploy Kyverno policy packs in audit mode for safe rollout
  • Graduate policies from audit to enforce using evidence from audit logs
  • Configure break-glass exceptions with expiry and evidence requirements
  • Evaluate policy coverage against the security baseline

Start with the video for the concept overview, then work through each lesson section.

Upstream guardrails (CI, PR reviews) are essential but can be bypassed. In this chapter, we implement a Cluster Gatekeeper using Kyverno. This is our final line of defense, ensuring that only workloads matching our production standards are admitted to the cluster.


1. The Problem: The “Policy Bypass”

A critical configuration error (like running as root or missing resource limits) slips through the CI/CD pipeline. Without a cluster-side check, the non-compliant workload runs in production, violating your security and stability invariants. The system’s safety depends entirely on every previous step being perfect.

2. The Concept: Cluster-Side Enforcement

We move from “hoping” the pipeline is correct to “enforcing” the state at the Kubernetes API boundary.

  1. Admission Control: Every request to create or update a resource is intercepted by a policy engine.
  2. Kyverno: A Kubernetes-native policy engine that uses standard YAML to define rules.
  3. Fail-Closed: If a workload violates a critical policy (e.g., Security Context), the cluster rejects the request entirely.

3. The Code: The Policy Pack

Our sre/ repo includes standard policy packs for security, resources, and best practices. These policies are the definitive contract for what is allowed to run in our cluster.

Supply chain policy example

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-signed-images-example
spec:
  validationFailureAction: Audit
  background: false
  rules:
    - name: verify-ghcr-signatures
      match:
        any:
          - resources:
              kinds:
                - Pod
      verifyImages:
        - imageReferences:
            - "${image_registry}/*"
          mutateDigest: true
          attestors:
            - entries:
                - keyless:
                    # Replace with your CI issuer and subject constraints.
                    issuer: "https://token.actions.githubusercontent.com"
                    subject: "https://github.com/${git_owner}/*"

4. The Guardrail: Audit-First Rollout

We never block traffic blindly. Every new policy starts in Audit mode, where violations are recorded in a PolicyReport but not blocked. Only after the audit is clean do we move the policy to Enforce mode.

5. Verification: Did I Get It?

Check your current cluster compliance and test the boundary:

# View compliance reports for the develop namespace
kubectl get policyreports -n develop
# Try to deploy a non-compliant pod (e.g., missing resource limits)
kubectl run policy-test --image=nginx

Expected Output: If an enforcement policy is active, the command should fail with an error message from Kyverno explaining the violation.


Detailed Lessons

Hands-On Materials

Labs, quizzes, and runbooks — available to course members.

  • Admission Policy Guardrails Scorecard (Template) Members
  • Lab: Admission Guardrails in Audit and Enforce Modes (Advanced) Members
  • Quiz: Chapter 16 (Admission Policy Guardrails) Members
  • Runbook: Admission Policy Operations (Advanced) Members

The Incident: The Policy Bypass

Result: The system’s safety depends entirely on upstream processes being perfect. A single mistake in the pipeline becomes a production vulnerability. Observed Symptoms What the team sees first: Workloads are …

Investigation & Containment

Safe investigation sequence: Identify Violation: Use kubectl get policyreports or check cluster events for denied requests. Trace Origin: Determine how the non-compliant workload reached the cluster (CI bypass, manual …

Workflow & Strategy

Kubernetes Native: Policies are written in YAML, not a specialized language like Rego. Mutation Capable: It can automatically inject sidecars or fix small label errors. Image Aware: Built-in support for verifying …

Lab & Completion

Done When You have completed this chapter when: You can demonstrate the difference between Audit and Enforce policy modes. You have successfully blocked a non-compliant pod at the cluster boundary. You can find and …