Skip to content

k8s import: kyverno.io Policy becomes K8s::Iam::Policy and the build changes its apiVersion #5071

Closed as not planned

Description

@lex00

Found with chant 0.124.95 while reading a clone of kubernetes/k8s.io at commit 2b3d9153 offline, for #5067.

chant import maps kind: Policy with apiVersion: kyverno.io/v1 to the lexicon's Policy class, which is K8s::Iam::Policy. The build then writes apiVersion: iam.services.k8s.aws/v1alpha1, and WK8501 reports unknown field "spec.background" and "spec.rules".

Files: kubernetes/aks-prow-build/prow/kyverno.yaml, kubernetes/eks-prow-build/prow/kyverno.yaml and the two kubernetes/ibm-*/prow/kyverno.yaml.

The round trip changes the apiVersion of a resource with no warning, so a build of the imported source would apply a different kind from the one in the file.

Wanted: class resolution matches on API group and kind together, never on kind alone. A kind whose group has no class is handled as in the unknown-kind case (untyped, with a warning).

Activity

  1. added
    bug
    area:k8s
    epic:estate-read
    on Nov 15, 2026
  2. lex00 commented on Nov 15, 2026

    @lex00
    ContributorAuthor

    Not planned: this no longer reproduces on current code.

    On main plus #5075, chant import of the kubernetes/k8s.io kyverno files writes ibm-ppc64le/prow/kyverno.yaml (Policy, kyverno.io/v1) as k8sManifest({ apiVersion: "kyverno.io/v1", kind: "Policy", ... }), with the warning that Policy (kyverno.io/v1) has no class in the lexicon. chant build of that output keeps apiVersion: kyverno.io/v1, kind: Policy, and WK8501 does not fire. ClusterPolicy behaves the same.

    The cause is gone with #5070. exportedClassFor accepts a lexicon class only when its resourceType equals the type the parser built from the group (K8s::Kyverno::Policy), so the packaged Policy entry for K8s::Iam::Policy (iam.services.k8s.aws/v1alpha1) is no longer picked. No other path checked maps a bare kind to a class: the serializer's resolveGVK, projectKindForType, deriveGVKFromType, operation-surface and index-import all key on the full K8s::<Group>::<Kind> type. The issue was found on 0.124.95, before #5070.

    While checking this, infra/gcp/bash/namespaces/namespace.yml (name: {{name}}) crashed the import in toLogicalId. It now imports with a warning that metadata.name is a mapping, likely a template placeholder. That fix goes into the next chant batch.

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

    area:k8sbugepic:estate-read

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions