Open Policy Agent 101

πŸ“– Series Overview

Policy enforcement is one of those problems that looks simple on day one and gets complicated fast. When I first set up a Kubernetes cluster for my personal projects, I just applied YAML and moved on. Then, as the setup grew β€” more namespaces, more workloads, a few team members sharing the cluster β€” I started noticing drift. Containers running as root. No resource limits. Images pulled from anywhere. Nothing enforcing the rules I thought I'd communicated.

That's what brought me to Open Policy Agent. OPA doesn't just enforce rules β€” it makes policy a first-class concern in your stack. Policies become code: versioned, tested, reviewed, deployed. This series documents what I learned building policy-as-code across local Kubernetes clusters and progressively more complex setups.


🎯 What You'll Learn

By working through this series, you'll understand:

  • What OPA is and how policy decoupling solves real engineering problems

  • Rego language β€” OPA's declarative policy language from first principles

  • Deployment modes β€” sidecar, server, and embedded library patterns

  • Kubernetes admission control using OPA Gatekeeper

  • Writing real Kubernetes policies for pod security, namespaces, and RBAC

  • Policy bundles β€” distributing and managing policies at scale

  • Testing policies with opa test and Conftest

  • CI/CD integration β€” shift-left policy enforcement in pipelines


πŸ—ΊοΈ Learning Path

spinner

πŸ“š Articles in This Series

#
Title
Description

01

What OPA is, why policy decoupling matters, core concepts

02

Syntax, rules, iteration, functions β€” learning to write policy

03

How OPA works, sidecar vs server vs library

04

Installing and configuring admission control on a cluster

05

Real policies: pod security, image registries, resource limits

06

Distributing policies, bundle server, policy versioning

07

Unit testing with opa test, Conftest, and policy coverage

08

Shift-left enforcement: validating IaC, manifests, configs


πŸ”§ Prerequisites

This series assumes you:

  • Are comfortable with Kubernetes basics (pods, deployments, namespaces, RBAC)

  • Have a working local Kubernetes cluster (kind, k3s, or minikube)

  • Know JSON and YAML at a working level

  • Have some experience with at least one declarative or functional language

  • Are running macOS or Linux for the examples


πŸ› οΈ Tools Used in This Series

Tool
Purpose
Install

opa CLI

Evaluate and test policies locally

brew install opa

kubectl

Interact with Kubernetes

brew install kubectl

kind or k3s

Local Kubernetes cluster

brew install kind

helm

Install Gatekeeper

brew install helm

conftest

Policy testing for configs

brew install conftest



OPA graduated as a CNCF project in 2021. It's production-proven across Kubernetes, CI/CD, API gateways, and microservices. This series focuses on understanding it deeply before applying it broadly.

Last updated