Skip to content

Migrate Kyverno ClusterPolicy and Policy before Kyverno 1.20 removes them #4984

Open
3 of 8 issues completed
Open

Description

@devantler

🤖 Generated by the Agentic Engineer (interactive Claude Code session)

Evidence

  • Kyverno 1.19 deprecates ClusterPolicy, Policy, CleanupPolicy, ClusterCleanupPolicy and the legacy kyverno.io PolicyException, calls 1.19 the final release with full support for them, and plans their removal for 1.20, estimated November 2026.
  • Production runs Kyverno 1.19.1. The repository has 49 ClusterPolicy manifests and one Policy; they carry almost every admission, mutation and generation rule the platform enforces.
  • The dependency rules for Kyverno do not hold it below 1.20, and KSail also installs Kyverno for the cluster (policyEngine: Kyverno), so the version can move from two places.

Problem

Installing Kyverno 1.20 before the policies are migrated would remove the platform's admission rules in one deploy.

Smallest useful change

Cap Kyverno below 1.20 in the dependency rules, with the removal condition recorded beside the cap, and confirm which Kyverno version KSail installs. Then migrate the policies to their replacement kinds in small batches, each validated with the existing policy tests.

Acceptance criteria

  • An update cannot propose Kyverno 1.20 while any legacy policy kind remains; the cap names its removal condition.
  • Every ClusterPolicy, Policy and legacy exception is migrated, and the policy tests pass on the new kinds.
  • The cap is removed and Kyverno 1.20 deployed only after the migration is live.

Size: large — the migration is the bulk; the cap is small.

Refinement (2026-10-17): decomposed

Corrected count. main has 49 kyverno.io/v1 ClusterPolicy manifests (22 validate, 23 mutate, 4 generate; none mixes rule types or uses verifyImages) and no kyverno.io Policy, CleanupPolicy, ClusterCleanupPolicy or legacy PolicyException. The platform already runs two new-style kinds: ImageValidatingPolicy (verify-app-images) and DeletingPolicy (prune-stale-policy-reports). 28 of the 49 are named in no Kyverno CLI test, so each batch starts by pinning current behaviour.

Children, in the order they can start:

The last criterion above (remove the cap and install 1.20) follows once every child is closed and 1.20 is released. This issue is now an Epic: it is delivered through its children.

Activity

  1. added theissue type on Oct 17, 2026
  2. moved this to 📥 Backlog in 🌊 Project Boardon Oct 17, 2026
  3. devantler commented on Oct 17, 2026

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer (interactive Claude Code session)

    Coordination note from today's kyverno-policies strategy review: the shared catalog now has devantler-tech/kyverno-policies#42 to port its own six classic policies to CEL kinds before Kyverno 1.20, and devantler-tech/kyverno-policies#45 to decide which of this repository's 49 classic policies are generic enough to port once in the catalog instead of here. Porting a generic policy in the catalog costs about the same and the platform template inherits it. Suggest starting this migration with the platform-specific policies and leaving the generic candidates until #45 records its decision.

  4. changed the issue type fromtoon Oct 17, 2026
  5. devantler commented on Oct 19, 2026

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer

    What the platform should not port itself — decided on devantler-tech/kyverno-policies#45 (2026-10-19):

    • Graduate to the catalog (10): validate-pod-security, validate-host-restrictions, audit-privileged-rbac, validate-pdb-drain-safe (Graduate the platform's pod-security, host, RBAC and drain-safety validation policies as ValidatingPolicy kyverno-policies#46); add-default-limitrange, add-ns-quota, disable-default-sa-automount, add-resource-defaults, insert-pod-antiaffinity, spread-pods-across-topology (Graduate the platform's namespace, service-account and scheduling default policies as CEL kinds kyverno-policies#47). The platform keeps only its namespace and object exclusions, as a consumer patch.
    • Retire in favour of the existing catalog policy (5): disallow-latest-tag, enforce-flux-best-practices, add-recommended-labels, helm-release-enable-tests, helm-release-install-crds. The platform's patch must keep the 11-namespace exclusion and CREATE-only matching (latest tag), and Enforce plus the flux-system, github-config and unifi carve-outs (Flux best practices).
    • Port in place (34): everything else, including auto-vpa (the catalog names VPAs differently, so switching would orphan existing ones) and helm-release-remediation-retries (the catalog's default retry count differs from the platform's 3).

    Precondition: the platform does not reference the catalog today. Until it consumes it (devantler-tech/kyverno-policies#9), none of the 15 can be removed from the platform; if that is not live in time for 1.20, the platform ports them in place after all.

    For #4996 this means: disallow-latest-tag and enforce-flux-best-practices are retired rather than rewritten here; validate-host-restrictions, validate-pdb-drain-safe and validate-pod-security graduate; validate-replica-ceiling, validate-replica-floor and the three Hetzner provider policies are ported in place. Their CLI tests already exist and stay as the acceptance check either way.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Epic.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions