homek8s/apps/base/sirius-growth/networkpolicy.yaml
Lance Walters 69b003705c infra(netpol): default-deny ingress+egress for the six app namespaces
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)
2026-11-27 02:19:10 -05:00

105 lines
4 KiB
YAML

# Tenant isolation for `sirius-growth` (audit finding F3 / A5-1, card t_fed52919).
#
# `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the
# deny. `sirius-growth-allow` (CiliumNetworkPolicy) re-adds what the namespace
# actually uses:
# ingress: Cilium Gateway proxy (`reserved:ingress`) for
# siriusgrowthsolutions.com -> site:80 / contact:8090 /
# portal-gate:8080 / portal:8091 / blog:8092, node entities for
# kubelet probes, and Prometheus in `monitoring` on 9187 only (the
# `cnpg-portal` PodMonitor scrapes the CNPG instance manager).
# egress: cluster DNS; its own pods (blog/portal -> portal-1:5432,
# portal-gate -> portal:8091); `world` for the Telegram Bot API
# (contact + portal) and the leadgen crawlers; the node IPs on 3900
# (Garage S3: 10.10.0.1 for blog/portal media, 10.10.0.5 for the
# portal WAL ObjectStore) and on 22 (leadgen-backup rsyncs to
# [email protected]); and `kube-apiserver` for the CNPG instance
# manager, which needs the API for leader/status updates.
#
# Garage lives on node IPs, which Cilium maps to `reserved:remote-node`, not
# `world` — see apps/base/siriusdevops/networkpolicy.yaml for the original
# measurement (an `ipBlock`/toCIDR rule for 10.10.0.1 is silently inert here).
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny
namespace: sirius-growth
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
---
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: sirius-growth-allow
namespace: sirius-growth
spec:
description: >-
sirius-growth: gateway + kubelet + Prometheus ingress; egress to own
namespace, cluster DNS, the internet, Garage/SSH on node IPs and the API.
endpointSelector: {}
ingress:
- fromEntities:
- ingress
- host
- remote-node
- health
# Intra-namespace pod -> pod (app -> db, sidecars, the backup CronJob).
# Cilium enforces policy at BOTH ends, so this allow must exist in ingress as
# well as egress — measured on `piedmont`: with only the egress rule a pod
# could not reach its own Service (TimeoutError).
- fromEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: sirius-growth
# Prometheus scrapes the CNPG `portal` instance manager on 9187.
- fromEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: monitoring
toPorts:
- ports:
- port: "9187"
protocol: TCP
egress:
- toEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: kube-system
k8s-app: kube-dns
toPorts:
- ports:
- port: "53"
protocol: UDP
- port: "53"
protocol: TCP
- toEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: sirius-growth
# Telegram Bot API + leadgen crawl targets.
- toEntities:
- world
# Garage S3 on the Pi (10.10.0.1) and the Linode (10.10.0.5); leadgen-backup
# SSH/rsync to [email protected]. Node IPs are `remote-node`, not `world`.
- toEntities:
- remote-node
toPorts:
- ports:
- port: "3900"
protocol: TCP
- port: "22"
protocol: TCP
# CNPG instance manager <-> kube-apiserver. Port-scoped on purpose: the
# apiserver is host-networked on 10.10.0.2, and Cilium attaches the
# `kube-apiserver` identity to that whole node IP — an unscoped entity rule
# also opens 8081/8084/8085/8086/8087 (the internal Gateway listeners) and
# :10250/:9100 on the same address. Measured: 10.10.0.2:8085 was OPEN from
# this namespace until the ports were named. 443 is the service port the
# CNPG instance manager dials (kubernetes.default:443 -> backend 6443).
- toEntities:
- kube-apiserver
toPorts:
- ports:
- port: "6443"
protocol: TCP
- port: "443"
protocol: TCP