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)
This commit is contained in:
parent
e5a0460e53
commit
69b003705c
15 changed files with 701 additions and 71 deletions
|
|
@ -19,6 +19,8 @@ resources:
|
|||
- news-scraper-deployment.yaml
|
||||
- news-summarizer-deployment.yaml
|
||||
- httproute.yaml
|
||||
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
||||
- networkpolicy.yaml
|
||||
# exec-only RBAC so forgejo/cluster-backup can pg_dump this namespace's plain
|
||||
# Postgres Deployment (osint-db) — not a CNPG cluster, so it needs its own path.
|
||||
- backup-exec-rbac.yaml
|
||||
|
|
|
|||
75
apps/base/osint/networkpolicy.yaml
Normal file
75
apps/base/osint/networkpolicy.yaml
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# Tenant isolation for `osint` (audit finding F3 / A5-1, card t_fed52919).
|
||||
#
|
||||
# `default-deny` (stock NetworkPolicy, podSelector {}, both directions) makes
|
||||
# every pod in this namespace reachable by nothing and able to reach nothing.
|
||||
# `osint-allow` (CiliumNetworkPolicy) re-adds the traffic the workload actually
|
||||
# uses, in both directions:
|
||||
# ingress: the Cilium Gateway proxy (`reserved:ingress`) for
|
||||
# osint.siriusdevops.com -> app:8000 / titiler:8000, plus node/health
|
||||
# entities for kubelet probes.
|
||||
# egress: cluster DNS, its own pods (app -> osint-db:5432, -> nats:4222,
|
||||
# -> titiler:8000), and `world` — the ingester/news-scraper/
|
||||
# news-summarizer fetch external news + Nominatim
|
||||
# (nominatim.openstreetmap.org) + the Nous inference API, and
|
||||
# camera-service reads RTSP cameras on the LAN.
|
||||
#
|
||||
# `world` in Cilium is everything outside the cluster (internet, LAN, VPN peers)
|
||||
# but NOT other namespaces' pods and NOT the node IPs — so cross-namespace
|
||||
# reachability and the internal WireGuard gateway ports stay closed.
|
||||
#
|
||||
# Deliberately absent:
|
||||
# * kube-apiserver egress — no workload here calls the API; the audit's
|
||||
# `SA token mounted` observation is a separate finding and denying the path
|
||||
# does not depend on removing the token.
|
||||
# * monitoring ingress — no PodMonitor/ServiceMonitor selects osint pods.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny
|
||||
namespace: osint
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
---
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: osint-allow
|
||||
namespace: osint
|
||||
spec:
|
||||
description: >-
|
||||
osint: gateway + kubelet ingress; egress to own namespace, cluster DNS and
|
||||
the public internet only.
|
||||
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: osint
|
||||
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: osint
|
||||
# Internet / LAN / VPN peers: news sources, Nominatim, inference API, RTSP.
|
||||
- toEntities:
|
||||
- world
|
||||
Loading…
Reference in a new issue