Skip to main content
← All posts·
AI Governance

Governance Automation: Policy-as-Code for AI Compliance at Scale

Manual governance doesn't scale past 10 AI models. Here's how to implement policy-as-code using OPA, Kyverno, and CI/CD gates to automate AI Act, DORA, and NIS2 compliance checks across the entire ML lifecycle.

Luca Berton15 min read

Governance that depends on humans reviewing documents, attending meetings, and manually checking boxes has a hard ceiling: about 10 AI models. Beyond that, the governance function becomes either a bottleneck that slows deployment to a crawl, or a rubber stamp that approves without meaningful review. Neither is acceptable in regulated industries.

The answer is governance automation — encoding regulatory requirements, organizational policies, and best practices into machine-executable rules that are enforced automatically at every stage of the AI lifecycle. Policy-as-code transforms governance from a periodic human activity into a continuous, automated control embedded in your infrastructure.

What Can Be Automated (and What Can't)

Automation Candidates

  • Fully automatable: Data quality gates, model documentation completeness, security configuration checks, deployment policy enforcement, access control verification, container image scanning, drift detection thresholds
  • Partially automatable: Fairness metric computation (automated) + interpretation (human), risk classification (rule-based initial + human review), regulatory mapping (template-driven + legal validation)
  • Human judgment required: Ethical assessment of edge cases, business value evaluation, strategic risk acceptance, regulatory interpretation of novel scenarios, stakeholder impact assessment

The goal isn't to eliminate human judgment — it's to reserve human judgment for decisions that genuinely require it, while automating the 70-80% of governance activities that are rule-based and repetitive.

The Governance Automation Stack

Layer 1: Policy Definition

Policies must be defined in a format that is both human-readable (for audit and review) and machine-executable (for enforcement):

Open Policy Agent (OPA) / Rego

OPA is the industry standard for policy-as-code. Rego is its declarative policy language:

# Policy: AI models must have complete documentation before production deployment
package ai.governance.deployment

default allow_deployment = false

allow_deployment {
    model_card_complete
    validation_report_exists
    fairness_metrics_within_threshold
    risk_classification_assigned
    data_lineage_documented
}

model_card_complete {
    input.model_card.purpose != ""
    input.model_card.training_data_description != ""
    input.model_card.performance_metrics != null
    input.model_card.limitations != ""
    input.model_card.ethical_considerations != ""
    input.model_card.owner != ""
}

fairness_metrics_within_threshold {
    input.fairness.demographic_parity_difference < 0.1
    input.fairness.equalized_odds_difference < 0.1
}

risk_classification_assigned {
    input.risk_tier >= 1
    input.risk_tier <= 3
}

Kyverno (Kubernetes-Native)

For organizations running AI workloads on Kubernetes, Kyverno provides policy enforcement at the cluster level:

# Policy: AI training jobs must have resource limits and security context
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: ai-training-security
spec:
  validatingAdmissionPolicy: true
  rules:
  - name: require-resource-limits
    match:
      any:
      - resources:
          kinds: [Pod]
          namespaceSelector:
            matchLabels:
              workload-type: ml-training
    validate:
      message: "AI training pods must have CPU and memory limits"
      pattern:
        spec:
          containers:
          - resources:
              limits:
                memory: "?*"
                cpu: "?*"
  - name: require-non-root
    match:
      any:
      - resources:
          kinds: [Pod]
          namespaceSelector:
            matchLabels:
              workload-type: ml-training
    validate:
      message: "AI training pods must run as non-root"
      pattern:
        spec:
          securityContext:
            runAsNonRoot: true

Policy Repository Structure

  • Git-managed: All policies stored in Git with version control, review workflows, and audit trail
  • Organized by domain: policies/data-quality/, policies/model-governance/, policies/security/, policies/deployment/
  • Tested: Every policy has unit tests verifying correct behavior (allow when compliant, deny when non-compliant)
  • Documented: Each policy file includes human-readable description, regulatory basis, and exemption process

Layer 2: Enforcement Points

Policies must be enforced at every stage of the AI lifecycle:

Data Pipeline Gates

  • Pre-training validation: Automated data quality checks before training begins — schema validation, null rate thresholds, distribution analysis, bias detection
  • Data access authorization: OPA evaluates whether the requesting workload identity has authorization to access specific datasets for the stated purpose
  • PII detection: Automated scanning for personal data in training datasets, flagging for governance review if PII is detected in datasets not classified for PII processing

Model Registry Gates

  • Registration policy: Models cannot be registered without minimum metadata (owner, purpose, training data reference, risk classification)
  • Promotion policy: Models cannot be promoted from dev → staging → production without passing governance checks for each environment
  • Artifact signing: Automated signing of model artifacts at registration. Unsigned models cannot be deployed

CI/CD Pipeline Gates

  • Pre-deployment checks: Automated verification of model card completeness, validation report, fairness metrics, security scan results
  • Image scanning: Container images scanned for vulnerabilities. Deployment blocked if critical or high CVEs are present
  • Configuration validation: Deployment configurations validated against security policies (network policies, resource limits, security contexts)

Runtime Enforcement

  • Kubernetes admission control: Kyverno or OPA Gatekeeper enforce policies on all resources deployed to the cluster
  • Network policies: Automated enforcement of network segmentation between training, validation, and production workloads
  • Runtime monitoring: Falco rules detecting anomalous behavior in AI workloads (unexpected network connections, file access patterns)

Layer 3: Continuous Compliance Monitoring

Enforcement at deployment time isn't enough. Compliance must be continuously verified:

  • Drift monitoring: Automated alerts when model performance metrics, data distributions, or fairness metrics drift beyond defined thresholds
  • Configuration drift: Continuous verification that deployed configurations match approved policies. Detect and alert on unauthorized changes
  • Certificate and credential expiry: Automated monitoring and rotation of workload identities, certificates, and access credentials
  • Compliance dashboards: Real-time visibility into governance compliance status across all AI systems

Layer 4: Automated Reporting

  • Governance status reports: Automated generation of compliance reports showing policy compliance rates, exceptions, and trends
  • Regulatory reports: Template-driven report generation for DORA, NIS2, and AI Act obligations, populated from automated monitoring data
  • Audit evidence: Automated collection and organization of audit evidence — policy decisions, access logs, validation results, deployment records
  • Board reporting: Executive dashboard summarizing AI governance posture, incidents, and compliance status
📘 Book

Kubernetes Recipes

A practical guide for container orchestration and deployment by Grzegorz Stencel & Luca Berton (Apress).

Watch on Skillshare →

Automation ROI

Quantifying the value of governance automation:

Efficiency Gains

  • Deployment time: Manual governance review: 2-4 weeks. Automated with human approval for exceptions: 2-4 days. For low-risk models with full automation: hours
  • Compliance audit preparation: Manual evidence collection: 4-8 weeks. Automated evidence platform: continuous (audit-ready at all times)
  • Incident detection: Manual review: days to weeks. Automated monitoring: minutes to hours
  • Governance team scaling: Manual governance scales linearly with model count. Automated governance: sublinear scaling — a team of 3 can govern 100+ models
  • Error reduction: Manual checks have 5-15% error rate. Automated checks: 0% for defined rules (with false positive management for heuristic checks)

Implementation Roadmap

Phase 1: Quick Wins (Months 1-2)

  1. Implement container image scanning in CI/CD (Trivy). Block deployments with critical CVEs
  2. Add model card completeness check to model registry (simple script in CI/CD)
  3. Deploy Kyverno with basic security policies for AI workload namespaces
  4. Set up automated drift alerting for production models (Prometheus + custom metrics)

Phase 2: Core Automation (Months 3-4)

  1. Deploy OPA for data access authorization and model promotion policies
  2. Implement automated fairness metric computation in CI/CD pipeline
  3. Build governance dashboard aggregating compliance status across all models
  4. Automate model artifact signing with Sigstore/cosign

Phase 3: Advanced Automation (Months 5-6)

  1. Implement automated regulatory reporting templates
  2. Deploy runtime security monitoring (Falco) with AI-specific rules
  3. Build audit evidence platform with continuous evidence collection
  4. Integrate governance automation with GRC platform for unified compliance view
🎓 Course with Starweaver

Microsoft SQL Server Performance Tuning

Performance tuning essentials for SQL Server. In collaboration with Starweaver.

Start on Coursera →

Common Mistakes

  1. Automating before defining: You can't automate policies you haven't written. Define policies in human-readable form first, then encode them
  2. All-or-nothing thinking: You don't need to automate everything at once. Start with the highest-volume, most error-prone governance activities
  3. Ignoring exceptions: Every automated policy needs an exception process. Without one, teams will route around the automation
  4. No testing: Policy-as-code must be tested like application code. A bug in a policy can block all deployments or — worse — allow non-compliant ones
  5. Forgetting the human: Automation should produce clear, actionable messages when it blocks something. "DENIED" is not helpful. "Deployment blocked: model card missing 'limitations' section. See docs/model-card-guide.md" is
governance automation
policy as code
opa
kyverno
compliance automation
ai act
dora
mlops
devsecops

Related Solution

Navigating AI adoption in a regulated environment? Our readiness assessment maps infrastructure, governance, and compliance gaps in 3-4 weeks.

Explore AI Readiness for Regulated Enterprises →

Need help applying this in your organization?

Get a free 30-minute assessment with actionable recommendations — whether we work together or not.

Book Your Free AI Platform Assessment

Or see AI readiness assessment scope & pricing

18+ years experience · Ex-Red Hat & Dell · Speaker at KubeCon EU 2026

Luca Berton

Written by

Luca Berton

CEO at Open Empower. 18+ years building enterprise infrastructure at JPMorgan Chase, Red Hat & Dell. Author of 9 technical books. Speaker at Red Hat Summit and KubeCon EU 2026. Instructor on Coursera, Pluralsight & Udemy.

Get more insights like this

Practical AI infrastructure and platform engineering guides — delivered to your inbox.

Subscribe to Newsletter →