Kyverno policies for the chart's defaults, and a test that bad values fail #22

Merged
jcoffey-dev merged 1 commits from feat/policy-checks into main 2026-11-19 01:37:57 +00:00
Owner

K-L3 (#10), with the namespace part already in #21.

lab/policy/defaults.yaml has four Kyverno ValidatingPolicies (CEL) for the defaults Pod Security "restricted" doesn't check. They apply in namespaces labelled inbuxa.org/policy=enforce, and through autogen to Deployments and Jobs, so a bad value is refused when it's applied rather than when a ReplicaSet can't make its pods:

  • every container has a read-only root filesystem
  • no service-account token, except the upgrade Job's
  • no secret in the environment (secretKeyRef, envFrom secrets). This one only warns until the chart's server image is rc.32 (inbuxa-charts#19); then it changes to Deny.
  • every pod is under a deny-all NetworkPolicy: both directions, no rules, a selector the pod matches

lab/policy/policy-test.sh uses server-side dry runs in a scratch namespace:

  • the chart as the lab installs it: every Deployment and Job is admitted
  • networkPolicy.enabled=false is refused (the bad value that fails the run)
  • a secret in webmail.extraEnv is flagged
  • the schema refuses webmail.securityContext, so no value turns the defaults off
  • an edited manifest with a writable root, a token, or an added capability is refused

up.sh installs Kyverno 1.19.2 (chart 3.9.2, released 2026-10-20) without the cleanup and reports controllers, applies the policies and labels the namespace. The README says how.

Run on the lab: policy-test passes. With the policies on, every Deployment in inbuxa restarted cleanly, with the one expected warning for the server's environment secret.

Not in this PR: checking image signatures. The images aren't cosign-signed yet (K-S7, K-W6, K-A2), so a policy for them couldn't be tested. An ImageValidatingPolicy for ghcr.io/inbuxa/* comes with that work. K-L3's done-when is met; I'd tick it and carry the signature check under K-S7.

K-L3 (#10), with the namespace part already in #21. **`lab/policy/defaults.yaml`** has four Kyverno ValidatingPolicies (CEL) for the defaults Pod Security "restricted" doesn't check. They apply in namespaces labelled `inbuxa.org/policy=enforce`, and through autogen to Deployments and Jobs, so a bad value is refused when it's applied rather than when a ReplicaSet can't make its pods: - every container has a read-only root filesystem - no service-account token, except the upgrade Job's - no secret in the environment (`secretKeyRef`, `envFrom` secrets). This one only warns until the chart's server image is rc.32 (inbuxa-charts#19); then it changes to Deny. - every pod is under a deny-all NetworkPolicy: both directions, no rules, a selector the pod matches **`lab/policy/policy-test.sh`** uses server-side dry runs in a scratch namespace: - the chart as the lab installs it: every Deployment and Job is admitted - `networkPolicy.enabled=false` is refused (the bad value that fails the run) - a secret in `webmail.extraEnv` is flagged - the schema refuses `webmail.securityContext`, so no value turns the defaults off - an edited manifest with a writable root, a token, or an added capability is refused **`up.sh`** installs Kyverno 1.19.2 (chart 3.9.2, released 2026-10-20) without the cleanup and reports controllers, applies the policies and labels the namespace. The README says how. **Run on the lab:** policy-test passes. With the policies on, every Deployment in `inbuxa` restarted cleanly, with the one expected warning for the server's environment secret. **Not in this PR:** checking image signatures. The images aren't cosign-signed yet (K-S7, K-W6, K-A2), so a policy for them couldn't be tested. An ImageValidatingPolicy for `ghcr.io/inbuxa/*` comes with that work. K-L3's done-when is met; I'd tick it and carry the signature check under K-S7.
jcoffey-dev added 1 commit 2026-11-19 01:24:30 +00:00
lab/policy/defaults.yaml: four ValidatingPolicies for what Pod Security
restricted doesn't check, in namespaces labelled inbuxa.org/policy=enforce:
a read-only root, no service-account token except the upgrade Job's, no
secret in the environment (warn until the chart's server image is rc.32),
and a deny-all NetworkPolicy over every pod. Autogen applies them to
Deployments and Jobs too.

lab/policy/policy-test.sh: the chart as the lab installs it is admitted;
networkPolicy.enabled=false is refused; a secret in extraEnv is flagged;
the schema refuses a securityContext value; a writable root, a token or an
added capability in an edited manifest are refused.

up.sh installs Kyverno 1.19.2 (chart 3.9.2) and the policies.
jcoffey-dev merged commit 548fa2f1ce into main 2026-11-19 01:37:57 +00:00
jcoffey-dev deleted branch feat/policy-checks 2026-11-19 01:37:57 +00:00
Sign in to join this conversation.