ci(l0): fix kyverno test expectations for CLI 1.13.4; pin kyverno-json 0.0.3
The offline `kyverno test` CLI cannot resolve the Flux postBuild token
${KYVERNO_VALIDATION_ACTION} in validationFailureAction, so the 4 policies
carrying it failed to load and their result rows reported "Not found" (14/17
cases). Render a throwaway copy of platform/kyverno with the base/prod value
(Enforce) before `kyverno test` in both ci/l0.sh and scripts/run-l0.sh; this
does not change in-cluster enforcement.
Add tests/values.yaml supplying Namespace labels so the offline CLI resolves
namespaceSelector matches -- without it the R-SEC-02/R-NET-05/R-IDP-02 Pod
cases were silently EXCLUDED (vacuous), not evaluated.
Pin kyverno-json 0.0.3 in ci/versions.env (0.0.5 has no upstream release;
0.0.3 is what run-l0.sh and the devcontainer already use).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
bb48f675ee
commit
08113ccfbb
5 files changed
+47
-3
No files matched your search
@@ -18,7 +18,18 @@ cd "$HERE/.."
|
||||
echo "== L0 gate: Kyverno CLI $KYVERNO_VERSION / kyverno-json $KYVERNO_JSON_VERSION =="
|
||||
|
||||
echo "-- [1/2] ClusterPolicy tests (kyverno test) --"
|
||||
kyverno test ./tests
|
||||
# The ClusterPolicies carry a Flux postBuild token in validationFailureAction
|
||||
# (${KYVERNO_VALIDATION_ACTION}, substituted in-cluster from clusters/base/cluster-vars.yaml).
|
||||
# The offline `kyverno test` CLI does not run Flux substitution, so render a throwaway copy
|
||||
# with the base/prod value (Enforce) before testing — otherwise those policies fail to load
|
||||
# and their result rows report "Not found". This does not change in-cluster enforcement.
|
||||
: "${KYVERNO_VALIDATION_ACTION:=Enforce}"
|
||||
L0_RENDER="$(mktemp -d)"
|
||||
trap 'rm -rf "$L0_RENDER"' EXIT
|
||||
cp -a . "$L0_RENDER/"
|
||||
find "$L0_RENDER" -type f -name '*.yaml' -print0 \
|
||||
| xargs -0 sed -i "s/\${KYVERNO_VALIDATION_ACTION}/${KYVERNO_VALIDATION_ACTION}/g"
|
||||
kyverno test "$L0_RENDER/tests"
|
||||
|
||||
echo "-- [2/2] ServiceDefinition validation (kyverno-json scan) --"
|
||||
kyverno-json scan \
|
||||
|
||||
@@ -6,6 +6,8 @@ apiVersion: cli.kyverno.io/v1alpha1
|
||||
kind: Test
|
||||
metadata:
|
||||
name: platform-kyverno-l0
|
||||
# Namespace labels for namespaceSelector resolution offline (see values.yaml).
|
||||
variables: values.yaml
|
||||
policies:
|
||||
- ../policies/require-default-deny-baseline.yaml
|
||||
- ../policies/validate-default-deny-shape.yaml
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Values for `kyverno test` -- supplies the Namespace LABELS the offline CLI needs to
|
||||
# resolve `namespaceSelector` matches (R-SEC-02/R-NET-05/R-IDP-02 policies scope by the
|
||||
# app-namespace label). Without this the engine cannot see a Namespace's labels for a
|
||||
# Pod under test, so every namespaceSelector rule is silently EXCLUDED and the pass/fail
|
||||
# assertions below become vacuous. These labels mirror resources/namespaces.yaml so the
|
||||
# app-namespace pods are genuinely evaluated and the platform-namespace pod is genuinely
|
||||
# out of scope (skip).
|
||||
apiVersion: cli.kyverno.io/v1alpha1
|
||||
kind: Values
|
||||
metadata:
|
||||
name: values
|
||||
namespaceSelector:
|
||||
- name: app-ns
|
||||
labels:
|
||||
homelab.keithjackson.dev/app-namespace: "true"
|
||||
- name: platform-ns
|
||||
labels:
|
||||
kubernetes.io/metadata.name: platform-ns
|
||||
Reference in new issue
Block a user