Files
home-network-k3s-impl/platform/kyverno/policies/validate-default-deny-shape.yaml
T
jakman85andClaude Opus 4.8 d9a80e5350 phase2-prep: per-component no-secret rollout + component hardening (author-first)
Prep only — nothing deployed; running cluster untouched.

Reconciliation graph (operator-approved Option A): author clusters/dev/rollout/
= 4 per-component Flux Kustomizations (kyverno->cilium->longhorn->monitoring,
monitoring dependsOn longhorn). Dev overlay $patch:delete's the monolithic base
platform/apps and adds ./rollout, so only the no-secret tier reconciles; the
secret-blocked components are simply not created until hand-offs arrive. The
no-secret tier carries no SOPS content, so it needs no sops-age key. prod is
untouched (still builds the monolith). Convergence path coded in (delete rollout/
+ the two deletes) — R-ENV-02 divergence flagged for architect review.

Component hardening via cluster-vars (prod keeps strict posture):
- KYVERNO_VALIDATION_ACTION Enforce->Audit(dev), _WEBHOOK_FAILURE_POLICY
  Fail->Ignore(dev), _ADMISSION_REPLICAS 3->1(dev); webhook namespaceSelector
  excludes system+platform namespaces.
- MONITORING_STORAGE_CLASS var; GRAFANA_ADMIN_SECRET var (dev ''=chart default);
  Alertmanager SMTP/secret deferred to Phase-4 with verbatim re-enable markers.

Cilium parity verified against the live CNI (no-op adopt). Validated:
kubectl kustomize dev/prod/all-components, envsubst->YAML parse, make -C ci gate PASS.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-08-16 21:34:57 -05:00

44 lines
1.7 KiB
YAML

# Serves: R-NET-01 (baseline must actually deny both directions)
# Spec: docs/03 "Deny all ingress and deny all egress by default".
#
# Catches a MALFORMED baseline: a NetworkPolicy claiming to be the default-deny
# baseline (label homelab.keithjackson.dev/baseline=default-deny) that does not
# actually cover BOTH Ingress and Egress is rejected. This is the "test the
# behavior, not the existence" guard for R-NET-01 at the manifest layer -- an
# object existing is not proof it denies (docs/14 principle 1).
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: validate-default-deny-shape
annotations:
policies.kyverno.io/title: Validate default-deny baseline shape
policies.kyverno.io/category: Network Isolation
policies.kyverno.io/severity: high
homelab.keithjackson.dev/requirements: R-NET-01
policies.kyverno.io/description: >-
A NetworkPolicy labelled as the default-deny baseline must set policyTypes
to include both Ingress and Egress. Rejects a baseline that silently leaves
a direction open.
spec:
validationFailureAction: ${KYVERNO_VALIDATION_ACTION}
background: true
rules:
- name: baseline-must-deny-both-directions
match:
any:
- resources:
kinds:
- NetworkPolicy
selector:
matchLabels:
homelab.keithjackson.dev/baseline: default-deny
validate:
message: >-
A default-deny baseline NetworkPolicy must set spec.policyTypes to include
BOTH Ingress and Egress (R-NET-01, docs/03).
pattern:
spec:
policyTypes:
- Ingress
- Egress