infra(netpol): default-deny ingress+egress for the six app namespaces #82
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_fed52919"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
Audit F3 / A5-1 (card
t_fed52919): the cluster had no network isolation. A pod in any namespacereached every other namespace's services, the API server, the internal WireGuard-only Gateway ports
on
10.10.0.2and the internet.customer1had no NetworkPolicy, no ResourceQuota and noLimitRange.
What this PR does
default-denyincustomer1,osint,sirius-growth,piedmont,siriusdevops,forgejo:a stock
networking.k8s.io/v1 NetworkPolicywithpodSelector: {}andpolicyTypes: [Ingress, Egress], no rules. Chosen over a CiliumClusterwideNetworkPolicy withendpointSelector: {}because a CCNP would also selectkube-system, CoreDNS and Flux and wouldneed dozens of allows before the cluster worked again.
<ns>-allowCiliumNetworkPolicy per namespace: gateway/kubelet/health entities,same-namespace pods, cluster DNS, then only the egress the workload uses —
world(Telegram / news / Nominatim / inference API / LAN cameras),remote-nodeon:3900(Garage) and
:22(backup rsync),kube-apiserveron:6443/:443for CNPG +cluster-backup.customer1gets no internet and no API egress.siriusdevops-site-egress(egress-only, one pod) is replaced by the namespace policy; itsmeasurement notes about
remote-nodevsipBlockare preserved in the new file.customer1quota.yaml: ResourceQuota + LimitRange sized from the declared 1-replica shape(35Gi already bound; 2 CPU / 4Gi requests, 4 CPU / 10Gi limits, 45Gi storage, 1 CPU / 2Gi per
container). The sandbox stays parked — the card forbids scaling it up.
docs/network-isolation.md: the model, the per-namespace matrix, and the five gotchas thatcost time while landing this (Cilium enforces at both ends;
kube-apiserveridentity covers thewhole node IP so it must be port-scoped;
ipBlockis inert for node IPs;worldexcludes nodesand pods; TimeoutError vs ConnectionRefusedError).
Evidence (live, 2026-11-27)
Before, from an
osintpod (the audit's probe) and from acustomer1probe pod — every target OPEN:After, from a
customer1pod:same-ns-pgrefuses rather than times out because the policy permits the path and the tenant isparked at 0 replicas; proven separately with a listener pod + client pod in
customer1(
OPEN same-ns-pod-to-pod 10.244.0.119:5432 payload=b'ok').Per-namespace probes (piedmont, osint, sirius-growth, siriusdevops, forgejo) confirm own-namespace
pods are
OPEN, cross-namespaceforgejo:3000/grafana:80/metabase:3000areCLOSED, theinternal Gateway ports are
CLOSED, and only the needed egress isOPEN:osint: internet OPEN, Garage/SSH/API CLOSED.sirius-growth: Garage10.10.0.1:3900+10.10.0.5:3900, SSH10.10.0.5:22, API OPEN; 8085/8081/9100/10250 CLOSED.
forgejo: own pg + API + SSH + internet OPEN; 8085/8081/9100/10250 CLOSED.siriusdevops: Garage 3900 OPEN; everything cross-namespace CLOSED.piedmont: Telegram OPEN; Garage/SSH CLOSED.Public routes all still serve (
curlfrom the laptop): siriusdevops.com 200 / www 200 //api/contact405, siriusgrowthsolutions.com 200 / www 301 //api/contact405,piedmonthomesvc.com 200 / www 200 /
/api/contact405, forgejo.siriusdevops.com 200,osint.siriusdevops.com 200 — identical to the pre-change codes.
No pod restarted after the change; Prometheus still scrapes both CNPG instances
(
up{namespace="forgejo"} = 1,cnpg_collector_up20s fresh); the deploy runner re-declared overthe public URL at 07:15:52Z.
Quota enforcement (server dry-run):
maximum memory usage per Container is 2Gi, but limit is 4Giand
exceeded quota: customer1-quota, requested: requests.cpu=3, used: requests.cpu=0, limited: requests.cpu=2.Out of scope (next tier):
metabase,monitoring,logging,kube-system,ci-runners,netsec,secopsare still unrestricted.Audit F3 / A5-1. Every pod in customer1, osint, sirius-growth, piedmont, siriusdevops and forgejo was reachable from every other pod, from the API server, from the internal WireGuard-only Gateway ports on 10.10.0.2 and from the internet. - each namespace: a stock NetworkPolicy 'default-deny' (podSelector {}, Ingress+Egress, no rules) plus a CiliumNetworkPolicy allow that names the gateway/kubelet/health entities, same-namespace pods, cluster DNS and only the egress each workload actually uses (world for Telegram/news/inference, remote-node :3900 for Garage, :22 for the backup rsync, kube-apiserver :6443 where CNPG/kubectl needs it, none at all for customer1) - siriusdevops: replaces the egress-only siriusdevops-site-egress CNP - customer1: ResourceQuota + LimitRange sized from the declared 1-replica shape (35Gi already bound, 2 CPU / 4Gi requests) - the sandbox stays parked - docs/network-isolation.md: the model plus the five gotchas measured while landing it (both-ends enforcement, kube-apiserver identity covering the whole node IP, remote-node vs world for Garage, ingress vs host identity)