Skip to content

k8s import: read a directory of manifests into one project for cross-file checks #5115

Closed

Description

@lex00

chant import takes one template file. A repository of plain manifests is therefore imported one file per project, and the k8s rules that look across objects only see the objects of that file. They then report what another file supplies. On kubernetes/k8s.io, per-file import and lint of 242 manifest files gave WK8503 ("Secret consumed, nothing produces it") 65 times in 19 files, FLUX002 (Kustomization names an undeclared GitRepository) 10 times and ARGO003 (cluster not registered) once, all errors. The Secrets come from ExternalSecrets or other files in the same directory, the k8s-io GitRepository is declared in another file of the Flux tree, and the cluster is registered in kubernetes/gke-utility/argocd/clusters.yaml. Read together, the same objects do not produce most of these: chant audit over the whole tree at the same commit, which runs all three rules, reported WK8503 once and FLUX002 and ARGO003 not at all.

Today

  • chant import (packages/core/src/cli/commands/import.ts) reads one file and writes one project.
  • k8s.kustomize.roots gives a directory with a kustomization.yaml one build, and chant audit merges every file it reads into one entity map before the post-synth pass (mergeEntities in packages/core/src/audit/core.ts).
  • A directory with no kustomization has neither, unless it is audited.

Wanted

  • chant import <dir> for the k8s lexicon reads every *.yaml and *.yml under the directory as manifests, writes one project with one source file per input file, and keeps the input path on each object, so a finding can name the file it came from.
  • A file that does not parse as manifests (a chart template, a values file) is skipped with a warning naming it, and the rest import.
  • The cross-file rules (WK8503, FLUX002, ARGO003 and the selector rules) then run over the whole directory with no change to the rules.
  • Decision for the implementer: whether a directory that a kustomization elsewhere lists in resources is imported again, the same question A workspace kind for plain manifest directories; keep ApplicationSet and AppProject #5096 leaves open for the graph.

Not in this

The graph-side join from an ExternalSecret to its store and cloud secret, which #5098 covers. Typed classes for CRD kinds, which #5070 covers.

Found while reading kubernetes/k8s.io offline, for #5067. Tracked on #5105.

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic:estate-read

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions