Kyverno CLI and conftest in CI vs Kyverno at admission
Kapitan compiles an inventory into plain YAML under compiled/ . The registry's compile diff action shows a reviewer what a pull request changes in that YAML. It does not say whether the change is allowed. A container that runs privileged or an image on the tag latest is one line in the diff, and Kapitan compiles it without an error. Kyverno as an admission controller can reject such an object…
The Kyverno CLI and conftest are both used in CI pipelines to check policies against compiled YAML files generated by Kapitan. The Kyverno CLI checks policy compliance on the compiled objects, while conftest runs Rego rules against those objects. Both tools run on two targets: one compliant and one noncompliant.
The compliant target specifies a Deployment with a restricted security profile, including using a non-root user, a default seccomp profile, no privilege escalation, and resource requests and limits. This target passes all 18 policy checks and exits with a 0 status code.
The noncompliant target, however, specifies a Deployment with a non-compliant security profile, including using the latest image tag, no resource requests or limits, and a privileged container. This target fails all 18 policy checks, with each policy providing a failure message. The Kyverno CLI exits with a 1 status code, indicating a failure.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.