Guides · Kubernetes & Delivery · Security · Kubernetes · DevSecOps
Kyverno vs OPA Gatekeeper: Policy as Code for Startups
· 3 min read
Policy as code is how modern clusters stay compliant without a human reviewing every manifest: rules run as admission controllers, so a pod that violates them never gets scheduled in the first place. Supply-chain incidents and SOC 2/SBOM expectations pushed this from nice-to-have to standard practice, and the tooling question comes down to two CNCF projects: Kyverno vs OPA Gatekeeper.
What’s the short answer?
Kyverno for most startups. Policies are plain Kubernetes YAML — anyone who can write a Deployment can read and write them. Gatekeeper policies are written in Rego, OPA’s purpose-built policy language: genuinely powerful, genuinely another language for your team to learn. If you don’t have a security engineer who already knows Rego, Kyverno’s learning curve is measured in hours, Gatekeeper’s in weeks.
Where each tool wins
Kyverno: YAML-native policies, first-class mutation (don’t just reject a bad manifest — fix it: add missing labels, default resource limits, set imagePullPolicy), resource generation (auto-create NetworkPolicies or quotas in new namespaces), and a large library of ready-made policies you can apply on day one.
Gatekeeper: Rego is a real language — complex cross-resource logic, data lookups, and policies you can reuse outside Kubernetes (the same OPA engine can gate Terraform plans and API requests). If policy-as-code across your whole stack is the goal, OPA is the bigger idea. For cluster guardrails alone, it’s more machinery than the job needs.
Which policies actually matter first?
The starter set we deploy — in audit mode first, then enforce — covers most of what an infrastructure compliance review checks:
- No
:latestimage tags - Resource requests and limits required
- No privileged containers, no root where avoidable
- Read-only root filesystem for stateless services
- Images only from your registries
- Liveness/readiness probes required
- No wildcard RBAC
- NetworkPolicy present in every namespace
- Required labels (owner, app) on workloads
- No hostPath/hostNetwork outside an allowlist
Pair admission policies with Trivy scanning images in CI (blocking on critical CVEs) and you’ve implemented “shift-left security” — findings surface at commit time, not in a post-incident audit.
Enforce or audit?
Start in audit mode always. Enforcing on an existing cluster on day one breaks deployments and burns the team’s goodwill. Run a week of audit, fix the violations, then flip to enforce with an emergency exception path. Guardrails should feel like guardrails, not a wall.
How does this connect to SOC 2?
Directly: auditors and the compliance platforms feeding them (Vanta, Drata) check for exactly the controls above — least privilege, image provenance, network segmentation, change control. Policies-as-code turn those from quarterly-audit findings into continuously-enforced invariants, which is why they’re a standard layer of our SOC 2-Ready Infrastructure package — guaranteed against your compliance platform’s infrastructure checks. The wider checklist lives in the SOC 2 infrastructure guide, and the cluster fundamentals underneath it on our Kubernetes page.
Not sure which of the ten policies your cluster would fail today? That’s an afternoon’s assessment inside the $1,900 audit — findings guaranteed or it’s free.
Newsletter
One practical DevOps guide a week
Real numbers, honest trade-offs, no vendor fog — same as everything here. Unsubscribe anytime.