Script icon
If icon
Pause icon
Patch icon
SlackIncomingWebhook icon
Webhook icon

Promote a Kyverno policy from audit to enforcement with admission proof

Promote a Kyverno policy from Audit to Deny with workload impact checks, human approval, live admission proof, and guarded rollback.

Categories
Infrastructure

Promote an existing namespace-scoped Kyverno validation policy using its Audit evidence and your own admission probes.

How it works

  1. Manual runs and the preview webhook read the policy spec and its Kyverno PolicyReports/OpenReports.
  2. PREVIEW changes nothing. ROLLOUT requires fresh evidence, at least one pass, no fail/warn/error/unknown results, and positive/negative JSON manifests. Both must pass in Audit.
  3. Review the spec and impact, confirm coverage and approve the fingerprint within 24 hours. Recheck before a conditional native patch changes only validationActions to Deny.
  4. Real dry-run admission must allow the positive probe and deny the negative probe through the selected policy. Failed verification conditionally restores only this execution's unchanged policy. Existing Deny policies are verified without taking ownership.

What you get

  • Impact: {{ outputs.assess.outputFiles['impact.json'] }}.
  • Decisions: {{ outputs.prove_admission.outputFiles['admission-proof.json'] }}.
  • Outcome: {{ outputs.summary.outputFiles['outcome.json'] }}; failures retain recovery artifacts.

Who it's for

Platform engineers promoting their own validation rules.

Why orchestrate this with Kestra

Separate evidence, human review, conditional promotion, live verification and recovery.

Prerequisites

Kyverno 1.19.2 (tested), NamespacedValidatingPolicy with webhook admission, Audit reporting, Kubernetes and Docker. Grant namespace get, policy get/patch, report list and probe-kind discovery/create. Reports must identify namespace/name. CREATE permissions allow real creates; this flow always uses dryRun=All.

Secrets

  • K8S_MASTER_URL: HTTPS API URL.
  • K8S_TOKEN: service-account token.
  • K8S_CA_CERT: base64 PEM CA.
  • KYVERNO_PREVIEW_WEBHOOK_KEY: preview key.
  • SLACK_WEBHOOK: optional failure alert.

Quick start

  1. Select your existing Audit policy; wait for reports of its current revision. This flow installs no policy.
  2. Defaults: SELECT mode=PREVIEW (or ROLLOUT); STRING target_namespace=policy-rollout-demo, policy_name=require-owner-data, kestra_url=http://localhost:8080; BOOL notify_slack=false; SELECT report_api=wgpolicyk8s.io/v1alpha2 (or openreports.io/v1alpha1); INT max_report_age_seconds=3600 (60..86400).
  3. Preview impact.json. For ROLLOUT supply FILE allowed_manifest and denied_manifest: distinct JSON CREATE objects for your rule, with target namespace and unique name/generateName. Any discoverable namespaced CREATE kind works; content and names are preserved.
  4. Resume with approved=true, plan_sha256 and audit_confirmed=true after reviewing coverage. Policy, findings and probes must match; refreshed timestamps are allowed but freshness is rechecked. Verify ENFORCED. No probe resources persist; enforcement stays active.
  5. The keyed webhook previews only. Set the Slack secret and notify_slack=true for alerts.

How to extend

Reports are asynchronous snapshots; missing evidence never means compliant. Review coverage explicitly. Limits: 500 reports, 1000 results, 1 MiB/probe. Hard termination/API outage may leave Deny active. Legacy or cluster-scoped policies need a separate scope/report design.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.