refactor(edge,iam): apply best practices to relay and Zitadel config

- edge: extract VPC/subnet/bandwidth/disk/DNS/Caddy settings into variables
- edge: add Caddyfile template with SSE-safe flush_interval -1 and security headers
- edge: add WireGuard NAT masquerade so homelab peer accepts forwarded client IPs
- edge: mark user_data sensitive and add prevent_destroy to the relay instance
- edge: validate relay_admin_cidr and Cloudflare hostnames
- edge: parameterise Cloudflare TTL/proxied and enforce proxied tunnel CNAMEs
- iam: fix PDB key to chart-supported pdb and remove unsupported extraVolumes
- iam: keep login hardened; drop unsupported login PDB
This commit is contained in:
pi
2026-10-25 18:03:55 -07:00
parent 6ebecec1c4
commit eb83aa6290
5 changed files with 211 additions and 12 deletions
+48
View File
@@ -39,6 +39,20 @@ zitadel:
requests: { memory: "512Mi", cpu: "250m" }
limits: { memory: "2Gi", cpu: "1" }
# Best practice: run as non-root, drop all capabilities, and refuse
# privilege escalation. The chart's image already supports a non-root UID.
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
# FirstInstance defaults stay for the FIRST sync: the chart creates org
# `zitadel` plus the `iam-admin` machine user and its machine-key Secret.
# Terraform consumes that key to declare projects, roles, OIDC apps and the
@@ -102,6 +116,25 @@ setupJob:
replicaCount: 2
revisionHistoryLimit: 3
# Best practice: a PDB guarantees at least one API pod stays available during
# voluntary disruptions (node drain, rolling upgrade). Without it a drain can
# take both replicas down at once. minAvailable 1 is correct for 2 replicas;
# minAvailable 2 would block every drain forever.
pdb:
enabled: true
minAvailable: 1
# Best practice: spread replicas across nodes so a single node failure cannot
# take both API pods. Anti-affinity alone only prefers separation; topology
# spread enforces the failure-domain budget.
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app.kubernetes.io/name: zitadel
ingress:
enabled: true
className: nginx
@@ -110,9 +143,24 @@ ingress:
login:
enabled: true
replicaCount: 1
revisionHistoryLimit: 3
ingress:
enabled: true
className: nginx
# Best practice: the login UI is the public attack surface. Harden the pod
# even at one replica. The chart has no login PDB key; a single replica has
# nothing to protect with minAvailable.
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
# Chart-owned ServiceMonitor. The cluster's Prometheus runs with
# serviceMonitorSelectorNilUsesHelmValues=false, so the release label is not