Skip to content

Migrate validate-host-restrictions to ValidatingPolicy #5140

Description

@devantler

🤖 Generated by the Agentic Engineer

Evidence and problem

Part of the Kyverno 1.20 migration (#4996): validate-host-restrictions is still a ClusterPolicy, which Kyverno 1.20 removes. Six of the epic's ten policies are migrated or in their final merge step (#5128); this is one of the four still running as a ClusterPolicy. Its behaviour was pinned by a CLI test in #5133, so it is the next one ready to move.

The policy denies Pods outside the infrastructure namespaces that use host paths or share the host's network, process or IPC namespaces, and denies hostUsers: true in namespaces opted into user namespaces (CloudNativePG pods excepted). It runs in Enforce for all three checks, so a wrong rewrite could either let a container-escape path through or block ordinary workloads from starting.

Smallest useful change

  1. Rewrite the policy as one ValidatingPolicy with the Deny action, Pods only (no controller autogen, matching today's behaviour), background evaluation, and three validations that keep each check's own scope: the same infrastructure-namespace exclusion for the host-path and host-namespace checks, and the same opt-in namespace label and CloudNativePG exclusion for the hostUsers check.
  2. Point the existing CLI test at the new kind. A ValidatingPolicy reports one result per resource instead of one per rule, so the expected results are restated per resource with the same outcome for every case the old test pinned.
  3. Delete the ClusterPolicy in the same change and record the policy by name in the failure-action baseline.

Acceptance criteria

  • The CLI test passes against the new kind with the same allow/deny outcome for every pinned case.
  • The failure-action baseline records validate-host-restrictions as Enforce.
  • kyverno test ./tests and the fixture-evaluation check pass in CI.
  • A read-only evaluation against the Pods running in production shows no Pod newly denied.
  • After deploy, the new policy reports ready and no ClusterPolicy named validate-host-restrictions remains.

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

Activity

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

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer

    Post-merge verification (#5141, read-only against production, 2026-10-20 ~22:50Z): the validate-host-restrictions ValidatingPolicy exists (created 22:32:13Z by the merge-queue deploy), reports ready=true, and enforces with Deny. The old ClusterPolicy of the same name is gone (NotFound). Before merge the same policy was applied read-only to all 324 running pods with 0 failures. Seven of the ten #4996 policies are now migrated.

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

Type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions