Skip to content

Migrate validate-replica-floor to ValidatingPolicy #5120

Description

@devantler

🤖 Generated by the Agentic Engineer

Evidence and problem

Part of the Kyverno 1.20 migration (#4996): validate-replica-floor is still a ClusterPolicy, which Kyverno 1.20 removes. It flags Deployments and StatefulSets running fewer than 2 replicas, so their drain-safe disruption budgets actually keep one pod serving through a node drain (#1882). Its behaviour is pinned by an existing CLI test, which covers only Deployments and explicit replica counts.

Smallest useful change

Extend the CLI test with an unset replica count, a scaled-to-zero Deployment and StatefulSets, prove it against the ClusterPolicy, then rewrite the policy as a ValidatingPolicy with the same Audit action and the same exemptions (the opt-out label on the workload or its pod template, the exempt namespaces, Flagger primaries and the named single-replica components), and delete the ClusterPolicy in the same change. Record it by name in the failure-action baseline.

Acceptance criteria

  • The extended CLI test passes with identical per-resource outcomes against both kinds.
  • The failure-action baseline records validate-replica-floor as Audit.
  • Evaluated against production's live Deployments and StatefulSets (read-only), the new policy reports the same outcome as the old one.
  • After deploy, the new policy reports ready and no ClusterPolicy of that name remains.

Priority High, Effort Low (one policy, one deploy). Service class Risk reduction, inherited from #4996.

Activity

  1. moved this to 🏃🏻‍♂️ In Progress in 🌊 Project Boardon Oct 20, 2026
  2. self-assigned this
    on Oct 20, 2026
  3. added a commit that references this issue on Oct 20, 2026
  4. moved this from 🏃🏻‍♂️ In Progress to 👀 In Review in 🌊 Project Boardon Oct 20, 2026
  5. moved this from 👀 In Review to 🚀 Ready to Merge in 🌊 Project Boardon Oct 20, 2026
  6. moved this from 🚀 Ready to Merge to ✅ Done in 🌊 Project Boardon Oct 20, 2026
  7. devantler commented on Oct 20, 2026

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer

    Post-deploy verification of #5121 (2026-10-20 ~14:10Z, read-only):

    • The new validate-replica-floor ValidatingPolicy is live and Ready, in Audit mode; the old ClusterPolicy of that name is gone.
    • Policy reports carry 92 results for it, all pass, none fail.
    • Control: an independent count of Deployments/StatefulSets below 2 replicas, minus every exemption the live policy declares (label, template label, namespace, -primary, named), returns zero — so zero fail is the expected answer, not a silent scanner.

    Nothing further owed on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

No fields configured for Refactor.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions