Skip to content

Migrate disallow-latest-tag to ValidatingPolicy #5115

Description

@devantler

🤖 Generated by the Agentic Engineer

Evidence and problem

Part of the Kyverno 1.20 migration (#4996): disallow-latest-tag is still a ClusterPolicy, which Kyverno 1.20 removes. It is one of the four policies on that list with no Kyverno CLI test, so nothing pins its behaviour across a rewrite today.

The policy keeps what runs reproducible: every container image must carry a tag, and the mutable :latest tag is refused. It runs in Audit, on Pod creation, outside the infrastructure namespaces that run third-party system charts.

Smallest useful change

  1. Add a Kyverno CLI test that pins today's behaviour and see it pass against the ClusterPolicy: a tagged image passes, a tagless image fails, :latest fails (for containers, init containers and ephemeral containers), a tag-plus-digest reference passes, and a Pod in an excluded namespace is skipped.
  2. Rewrite the policy as a ValidatingPolicy with the same Audit action, Pod CREATE scope, background evaluation and namespace exclusions, and delete the ClusterPolicy in the same change.
  3. Record the policy by name in the failure-action baseline.

Acceptance criteria

  • The new CLI test passes against the ClusterPolicy before the rewrite, and passes unchanged in its expected results against the new kind.
  • The failure-action baseline records disallow-latest-tag as Audit.
  • kyverno test ./tests and the fixture-evaluation check pass in CI.
  • After deploy, the new policy reports ready and no ClusterPolicy named disallow-latest-tag remains.

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

Activity

  1. self-assigned this
    on Oct 20, 2026
  2. moved this to 🏃🏻‍♂️ In Progress in 🌊 Project Boardon 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. devantler commented on Oct 20, 2026

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer

    Correction to step 1 of this issue: the CLI test that pins this policy already exists (#5066), so that step was done before this issue was filed. The draft #5116 reuses it, collapses its per-rule expectations into per-policy ones, and adds debug-container fixtures.

  6. moved this from 👀 In Review to 🚀 Ready to Merge in 🌊 Project Boardon Oct 20, 2026
  7. moved this from 🚀 Ready to Merge to ✅ Done in 🌊 Project Boardon Oct 20, 2026
  8. devantler commented on Oct 20, 2026

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer

    Post-deploy check (read-only, production, 2026-10-20 ~11:40Z): ValidatingPolicy/disallow-latest-tag is READY=true, ClusterPolicy/disallow-latest-tag no longer exists, and its PolicyReport results are being written (345 current pass, 0 fail). The last acceptance criterion holds.

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