Files
home-network-k3s-impl/platform/kyverno/policies/require-auth-mode-label.yaml
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

49 lines
2.1 KiB
YAML

# Serves: R-IDP-02 (every service authenticates against the IdP; no unauthenticated UI)
# Spec: docs/15-identity-and-access.md; docs/13 `auth.mode: oidc|forward-auth|native|none`.
#
# Every workload must declare which authentication mode it uses so the platform can
# wire the correct integration (native OIDC Keycloak client, oauth2-proxy forward-auth
# at the Gateway, a documented `native` exception e.g. Plex, or `none`). A missing
# auth declaration would let a bare management UI onto the network unprotected, which
# docs/15 forbids ("no management UI sits unauthenticated").
#
# Matches Pods; pod-controller autogen extends to Deployment/StatefulSet/etc.
# LABEL KEY is a PROPOSED contract owned jointly with WS-SEC/WS-GITOPS -- see
# platform/kyverno/labels.md. The VALUES are fixed by docs/13.
# NOTE: `none` is permitted by the enum (docs/13) but is "discouraged / internal-only";
# the ServiceDefinition-level policy additionally forbids `public` + `none`.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-auth-mode-label
annotations:
policies.kyverno.io/title: Require auth-mode label on workloads
policies.kyverno.io/category: Identity
policies.kyverno.io/severity: medium
homelab.keithjackson.dev/requirements: R-IDP-02
policies.kyverno.io/description: >-
Pods in application namespaces must declare
homelab.keithjackson.dev/auth-mode = oidc | forward-auth | native | none.
spec:
validationFailureAction: ${KYVERNO_VALIDATION_ACTION}
background: true
rules:
- name: require-auth-mode
match:
any:
- resources:
kinds:
- Pod
namespaceSelector:
matchLabels:
homelab.keithjackson.dev/app-namespace: "true"
validate:
message: >-
Pods in application namespaces must carry the label
homelab.keithjackson.dev/auth-mode set to one of
oidc | forward-auth | native | none (R-IDP-02, docs/15).
pattern:
metadata:
labels:
homelab.keithjackson.dev/auth-mode: "oidc | forward-auth | native | none"