implementing-policy-as-code-with-open-policy-agent

Featured

This skill covers implementing Open Policy Agent (OPA) and Gatekeeper for policy-as-code enforcement in Kubernetes and CI/CD pipelines. It addresses writing Rego policies, deploying OPA Gatekeeper as a Kubernetes admission controller, testing policies in development, and integrating policy evaluation into deployment pipelines.

AI & Automation 36,355 stars 4443 forks Updated 2 months ago Apache-2.0

Install

View on GitHub

Quality Score: 94/100

Stars 20%
100
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Implementing Policy as Code with Open Policy Agent ## When to Use - When enforcing organizational security policies across Kubernetes clusters programmatically - When requiring admission control that blocks non-compliant resources from being created - When implementing policy governance that can be version-controlled, tested, and audited - When standardizing security rules across multiple clusters and environments - When needing a flexible policy engine that extends beyond Kubernetes to APIs and CI/CD **Do not use** for vulnerability scanning (use Trivy/Checkov), for runtime threat detection (use Falco), or for network policy enforcement (use Kubernetes NetworkPolicy or Calico). ## Prerequisites - Kubernetes cluster with admin access for Gatekeeper installation - Helm for Gatekeeper deployment - OPA CLI or conftest for local policy testing - Rego knowledge for policy authoring ## Workflow ### Step 1: Install OPA Gatekeeper ```bash # Install Gatekeeper via Helm helm repo add gatekeeper https://open-policy-agent.github.io/gatekeeper/charts helm install gatekeeper gatekeeper/gatekeeper \ --namespace gatekeeper-system --create-namespace \ --set replicas=3 \ --set audit.replicas=1 \ --set audit.writeToRAMDisk=true ``` ### Step 2: Create Constraint Templates ```yaml # templates/k8s-required-labels.yaml apiVersion: templates.gatekeeper.sh/v1 kind: ConstraintTemplate metadata: name: k8srequiredlabels spec: crd: spec: names: kind: K8sRequiredL...

Details

Author
mukul975
Repository
mukul975/Anthropic-Cybersecurity-Skills
Created
8 months ago
Last Updated
2 months ago
Language
Python
License
Apache-2.0

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

implementing-opa-gatekeeper-for-policy-enforcement

Enforce Kubernetes admission policies using OPA Gatekeeper with ConstraintTemplates, Rego rules, and the Gatekeeper policy library.

36,355 Updated 2 months ago
mukul975
DevOps & Infrastructure Listed

policy-opa

Policy-as-code enforcement and compliance validation using Open Policy Agent (OPA). Use when: (1) Enforcing security and compliance policies across infrastructure and applications, (2) Validating Kubernetes admission control policies, (3) Implementing policy-as-code for compliance frameworks (SOC2, PCI-DSS, GDPR, HIPAA), (4) Testing and evaluating OPA Rego policies, (5) Integrating policy checks into CI/CD pipelines, (6) Auditing configuration drift against organizational security standards, (7) Implementing least-privilege access controls.

487 Updated today
aiskillstore
DevOps & Infrastructure Listed

k8s-gatekeeper-troubleshooting

Use when OPA Gatekeeper blocks, warns about or fails to police resources in Kubernetes: "admission webhook \"validation.gatekeeper.sh\" denied the request: [constraint] message", warnings from constraints in warn mode, a constraint that should block but only shows violations in audit (dryrun), a ConstraintTemplate that does not compile (ingest_error, rego_parse_error), "no matches for kind" when applying a constraint, referential policies that never fire (sync), mutations that do not apply, or Gatekeeper that stopped enforcing because its webhook is down. Investigates with kubectl get, describe and logs, and proposes fixes. Reads first and asks before changing anything.

38 Updated 3 days ago
k8s-servant