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,10 @@ resources:
|
|||
- metabase.yaml
|
||||
- backup.yaml
|
||||
- httproute.yaml
|
||||
# Default-deny ingress+egress + the tenant's allow list (audit F3 / t_fed52919).
|
||||
- networkpolicy.yaml
|
||||
# Tenant guardrails sized from the declared 1-replica shape (same card).
|
||||
- quota.yaml
|
||||
# Secrets, SOPS/age-encrypted in git. Flux decrypts them (the `apps`
|
||||
# Kustomization carries a decryption block; key = flux-system/sops-age).
|
||||
# Never add a plaintext Secret next to these — see docs/secrets-sops.md.
|
||||
|
|
|
|||
78
apps/base/customer1/networkpolicy.yaml
Normal file
78
apps/base/customer1/networkpolicy.yaml
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Tenant isolation for `customer1` (audit finding F3 / A5-1, card t_fed52919).
|
||||
#
|
||||
# Two objects, two jobs:
|
||||
# 1. `default-deny` (networking.k8s.io/v1) selects every pod in the namespace
|
||||
# for BOTH directions and allows nothing. It is the only object here that
|
||||
# creates a deny — a Kubernetes NetworkPolicy with `podSelector: {}` and no
|
||||
# rules is an unambiguous deny-all in Cilium's k8s-policy path, and unlike a
|
||||
# CiliumClusterwideNetworkPolicy with `endpointSelector: {}` it cannot
|
||||
# accidentally select kube-system/Flux/CoreDNS.
|
||||
# 2. `customer1-allow` (CiliumNetworkPolicy) re-adds exactly the traffic the
|
||||
# tenant needs. Cilium unions all policies that select an endpoint, so the
|
||||
# deny above plus this allow list is the effective policy.
|
||||
#
|
||||
# Why a CiliumNetworkPolicy for the allows: the sources to permit are Cilium
|
||||
# *entities* (`ingress` = the Gateway listener proxy, `host` = the node/kubelet),
|
||||
# which a stock NetworkPolicy cannot name.
|
||||
#
|
||||
# What this namespace is allowed to talk to — and nothing else:
|
||||
# * its own pods (odoo/metabase -> pg:5432, the pg-backup CronJob -> pg),
|
||||
# * kube-dns on 53.
|
||||
# It gets NO internet egress (world) and NO API-server egress: the sandbox has
|
||||
# no external dependency (backup.yaml: dumps stay on the local PVC, the Job has
|
||||
# `automountServiceAccountToken: false`). If odoo/metabase are ever resumed and
|
||||
# need an external service, add it here explicitly — that is the point.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny
|
||||
namespace: customer1
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
---
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: customer1-allow
|
||||
namespace: customer1
|
||||
spec:
|
||||
description: >-
|
||||
Customer-1 tenant: gateway + kubelet ingress only, egress to own namespace
|
||||
and cluster DNS only.
|
||||
endpointSelector: {}
|
||||
ingress:
|
||||
# reserved:ingress Cilium Gateway/listener proxy on siriussec (8086/8087)
|
||||
# reserved:host this node's kubelet probes / host-network datapath
|
||||
# reserved:remote-node node-sourced traffic when the pod is on another node
|
||||
# reserved:health cilium-health probes
|
||||
- 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: customer1
|
||||
egress:
|
||||
# Cluster DNS (CoreDNS only).
|
||||
- toEndpoints:
|
||||
- matchLabels:
|
||||
io.kubernetes.pod.namespace: kube-system
|
||||
k8s-app: kube-dns
|
||||
toPorts:
|
||||
- ports:
|
||||
- port: "53"
|
||||
protocol: UDP
|
||||
- port: "53"
|
||||
protocol: TCP
|
||||
# Intra-namespace only: odoo/metabase -> pg:5432 and the backup Job -> pg.
|
||||
- toEndpoints:
|
||||
- matchLabels:
|
||||
io.kubernetes.pod.namespace: customer1
|
||||
80
apps/base/customer1/quota.yaml
Normal file
80
apps/base/customer1/quota.yaml
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# `customer1` tenant guardrails (audit finding F3 / A5-1, card t_fed52919).
|
||||
#
|
||||
# The sandbox is parked (`replicas: 0`, `suspend: true`, both committed in Git —
|
||||
# see the README and the F21 note in the audit), so these numbers are derived
|
||||
# from the DECLARED shape, not from `kubectl top` of a running tenant. Measured
|
||||
# 2026-11-27 with `kubectl -n customer1 get deploy -o json` +
|
||||
# `get cronjob pg-backup -o json`:
|
||||
#
|
||||
# workload requests limits replicas
|
||||
# metabase 250m / 1Gi 1 CPU / 2Gi 0 (-> 1 when resumed)
|
||||
# odoo 200m / 512Mi – / 2Gi 0 (-> 1)
|
||||
# pg 100m / 256Mi – / 1Gi 0 (-> 1)
|
||||
# pg-backup 50m / 128Mi – / 512Mi suspended Job
|
||||
# ------------------------------------------------------------------
|
||||
# total 600m / 1.88Gi 1 CPU / 5.5Gi at 1 replica + 1 Job
|
||||
#
|
||||
# The quota is the declared total with room for the one thing that always
|
||||
# happens on a resumed stack: a RollingUpdate keeps maxSurge=25% of one replica
|
||||
# alive next to the old pod. So requests get ~2x headroom (2 CPU / 4Gi), limits
|
||||
# ~2x the declared peak (4 CPU / 10Gi) — a tenant cannot use more than two
|
||||
# replicas' worth of anything at once, and a runaway pod is still cut off by its
|
||||
# own limit, which is the LimitRange's job.
|
||||
#
|
||||
# Storage: 35Gi is already bound (odoo-data 10Gi + odoo-extra-addons 5Gi +
|
||||
# pg-data 10Gi + backup-data 10Gi) — measured with `kubectl -n customer1 get
|
||||
# pvc`. 45Gi allows exactly one more 10Gi claim and nothing more.
|
||||
#
|
||||
# Do not copy these numbers to another namespace: they describe this stack.
|
||||
apiVersion: v1
|
||||
kind: ResourceQuota
|
||||
metadata:
|
||||
name: customer1-quota
|
||||
namespace: customer1
|
||||
labels:
|
||||
app.kubernetes.io/part-of: customer1
|
||||
spec:
|
||||
hard:
|
||||
# Compute. Requests ~2x the declared 1-replica total (550m/1792Mi).
|
||||
requests.cpu: "2"
|
||||
requests.memory: 4Gi
|
||||
limits.cpu: "4"
|
||||
limits.memory: 10Gi
|
||||
# Object counts. 3 workloads x 2 pods during a rolling update = 6, plus the
|
||||
# pg-backup Job and room for one debug pod.
|
||||
pods: "12"
|
||||
count/jobs.batch: "8"
|
||||
count/cronjobs.batch: "2"
|
||||
services: "6"
|
||||
# Storage: 35Gi bound -> one more 10Gi claim.
|
||||
requests.storage: 45Gi
|
||||
persistentvolumeclaims: "6"
|
||||
---
|
||||
# Container defaults so the quota above is satisfiable by every pod in the
|
||||
# namespace: a ResourceQuota that constrains requests.cpu/limits.cpu rejects any
|
||||
# pod without them, and the LimitRange injects them. `max` is the per-container
|
||||
# ceiling — 2Gi is exactly metabase's declared limit, so the parked stack
|
||||
# schedules unchanged when it is resumed; anything bigger now needs a namespace
|
||||
# change on purpose.
|
||||
apiVersion: v1
|
||||
kind: LimitRange
|
||||
metadata:
|
||||
name: customer1-limits
|
||||
namespace: customer1
|
||||
labels:
|
||||
app.kubernetes.io/part-of: customer1
|
||||
spec:
|
||||
limits:
|
||||
- type: Container
|
||||
defaultRequest:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
default:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
max:
|
||||
cpu: "1"
|
||||
memory: 2Gi
|
||||
min:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
|
|
@ -6,6 +6,8 @@ resources:
|
|||
- namespace.yaml
|
||||
- ci-runners-namespace.yaml
|
||||
- httproute.yaml
|
||||
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
||||
- networkpolicy.yaml
|
||||
- pvc.yaml
|
||||
- cluster.yaml
|
||||
- podmonitor.yaml
|
||||
|
|
|
|||
103
apps/base/forgejo/networkpolicy.yaml
Normal file
103
apps/base/forgejo/networkpolicy.yaml
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
# Tenant isolation for `forgejo` (audit finding F3 / A5-1, card t_fed52919).
|
||||
#
|
||||
# `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the
|
||||
# deny. `forgejo-allow` (CiliumNetworkPolicy) re-adds what this namespace uses:
|
||||
# ingress: the Cilium Gateway proxy (`reserved:ingress`) for
|
||||
# forgejo.siriusdevops.com -> forgejo:3000. The CI runners live in
|
||||
# `ci-runners` and register/poll over the PUBLIC URL
|
||||
# (runner-amd64.yaml: `--instance https://forgejo.siriusdevops.com`),
|
||||
# so they arrive through the Gateway as `reserved:ingress` too and no
|
||||
# cross-namespace rule is needed. Node/health entities cover kubelet
|
||||
# probes; Prometheus in `monitoring` is allowed on 9187 only (the
|
||||
# `cnpg-pg` PodMonitor scrapes the CNPG instance manager).
|
||||
# egress: cluster DNS; its own pods (forgejo -> pg-rw:5432); `world` for
|
||||
# outbound HTTPS (Forgejo webhooks, avatar/mirror fetches, the
|
||||
# public-URL callbacks the runner flow needs); node IPs on 22, which
|
||||
# is the nightly `cluster-backup` CronJob rsyncing to
|
||||
# [email protected]; and `kube-apiserver`, needed by the CNPG instance
|
||||
# manager and by cluster-backup's `kubectl get cluster` /
|
||||
# `kubectl exec` DB dumps.
|
||||
#
|
||||
# The CI runner pods themselves are NOT in this namespace (they moved to
|
||||
# `ci-runners` for `enforce: privileged`) and are out of scope for this card.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny
|
||||
namespace: forgejo
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
---
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: forgejo-allow
|
||||
namespace: forgejo
|
||||
spec:
|
||||
description: >-
|
||||
forgejo: gateway + kubelet + Prometheus ingress; egress to own namespace,
|
||||
cluster DNS, the internet, 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: forgejo
|
||||
# Prometheus scrapes the CNPG `pg` 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: forgejo
|
||||
# Outbound HTTPS: webhooks, mirrors, avatar fetching.
|
||||
- toEntities:
|
||||
- world
|
||||
# cluster-backup rsync/ssh to [email protected] (the Linode node).
|
||||
- toEntities:
|
||||
- remote-node
|
||||
toPorts:
|
||||
- ports:
|
||||
- port: "22"
|
||||
protocol: TCP
|
||||
# CNPG instance manager and cluster-backup's kubectl calls. 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
|
||||
# kubectl dials (kubernetes.default:443 -> backend 6443).
|
||||
- toEntities:
|
||||
- kube-apiserver
|
||||
toPorts:
|
||||
- ports:
|
||||
- port: "6443"
|
||||
protocol: TCP
|
||||
- port: "443"
|
||||
protocol: TCP
|
||||
|
|
@ -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
|
||||
|
|
@ -7,6 +7,8 @@ resources:
|
|||
- service.yaml
|
||||
- service-api.yaml
|
||||
- httproute.yaml
|
||||
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
||||
- networkpolicy.yaml
|
||||
# Secrets, SOPS/age-encrypted in git. Flux decrypts them (the `apps`
|
||||
# Kustomization carries a decryption block; key = flux-system/sops-age).
|
||||
# Never add a plaintext Secret next to these — see docs/secrets-sops.md.
|
||||
|
|
|
|||
63
apps/base/piedmont/networkpolicy.yaml
Normal file
63
apps/base/piedmont/networkpolicy.yaml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# Tenant isolation for `piedmont` (audit finding F3 / A5-1, card t_fed52919).
|
||||
#
|
||||
# `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the
|
||||
# deny. `piedmont-allow` (CiliumNetworkPolicy) re-adds:
|
||||
# ingress: the Cilium Gateway proxy (`reserved:ingress`) for
|
||||
# piedmonthomesvc.com -> site:80 / contact:8090, plus node/health
|
||||
# entities for kubelet probes.
|
||||
# egress: cluster DNS; its own pods (nginx may proxy /api/contact in-namespace);
|
||||
# and `world` for the Telegram Bot API used by piedmont-contact.
|
||||
#
|
||||
# `world` is everything outside the cluster (internet, LAN, VPN peers) but not
|
||||
# other namespaces' pods and not node IPs, so the tenant boundary holds.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny
|
||||
namespace: piedmont
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
---
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: piedmont-allow
|
||||
namespace: piedmont
|
||||
spec:
|
||||
description: >-
|
||||
piedmont: gateway + kubelet ingress; egress to own namespace, cluster DNS
|
||||
and the public internet only.
|
||||
endpointSelector: {}
|
||||
ingress:
|
||||
- fromEntities:
|
||||
- ingress
|
||||
- host
|
||||
- remote-node
|
||||
- health
|
||||
# Intra-namespace: nginx -> contact (and any future pod -> pod call). Cilium
|
||||
# enforces policy at BOTH ends, so the same-namespace allow must exist in
|
||||
# ingress as well as egress — measured: with only the egress rule, a pod in
|
||||
# this namespace could not reach its own Service (TimeoutError).
|
||||
- fromEndpoints:
|
||||
- matchLabels:
|
||||
io.kubernetes.pod.namespace: piedmont
|
||||
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: piedmont
|
||||
# Telegram Bot API (contact form delivery).
|
||||
- toEntities:
|
||||
- world
|
||||
|
|
@ -14,6 +14,8 @@ resources:
|
|||
- service-blog.yaml
|
||||
- service-portal-gate.yaml
|
||||
- httproute.yaml
|
||||
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
||||
- networkpolicy.yaml
|
||||
# The WAL archive store must exist before the Cluster references it.
|
||||
- objectstore-portal-wal.yaml
|
||||
- cluster.yaml
|
||||
|
|
|
|||
105
apps/base/sirius-growth/networkpolicy.yaml
Normal file
105
apps/base/sirius-growth/networkpolicy.yaml
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
# 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
|
||||
|
|
@ -7,7 +7,9 @@ resources:
|
|||
- service-site.yaml
|
||||
- service-api.yaml
|
||||
- httproute.yaml
|
||||
- networkpolicy-site-egress.yaml
|
||||
# Replaces the egress-only `siriusdevops-site-egress` CNP: same Garage +
|
||||
# DNS allow, plus a namespace-wide default-deny and ingress rules (F3).
|
||||
- networkpolicy.yaml
|
||||
# Secrets, SOPS/age-encrypted in git. Flux decrypts them (the `apps`
|
||||
# Kustomization carries a decryption block; key = flux-system/sops-age).
|
||||
# Never add a plaintext Secret next to these — see docs/secrets-sops.md.
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
# Egress policy for the public site pod — the first policy in this namespace
|
||||
# (there were zero before 2026-11-19, so every pod could reach every WireGuard
|
||||
# address).
|
||||
#
|
||||
# What it is for: `siriusdevops-site` runs an initContainer that pulls owner
|
||||
# media out of the private Garage bucket over the mesh
|
||||
# (http://10.10.0.1:3900). Nothing else about that pod needs to talk to the
|
||||
# WireGuard network, and the pod is internet-facing, so it is the right first
|
||||
# pod to fence off.
|
||||
#
|
||||
# WHY A CiliumNetworkPolicy AND NOT A networking.k8s.io NetworkPolicy:
|
||||
# 10.10.0.1 is a CLUSTER NODE (rpi, the WireGuard hub), not a bare address.
|
||||
# Cilium resolves it to `reserved:remote-node` (identity 6) in its ipcache
|
||||
# (`cilium-dbg bpf ipcache list | grep 10.10.0.1` -> identity=6), and `ipBlock`
|
||||
# / toCIDR rules are only evaluated for `reserved:world`. A standard
|
||||
# NetworkPolicy with `ipBlock: 10.10.0.1/32` is silently inert here — measured:
|
||||
# the pod's request to 10.10.0.1:3900 timed out exactly like the denied ports,
|
||||
# while Prometheus (unrestricted namespace) scraped the same host fine.
|
||||
#
|
||||
# The narrower `toNodes: [{matchLabels: {kubernetes.io/hostname: rpi}}]` form
|
||||
# would name the node exactly, but the agent rejects it unless Cilium runs with
|
||||
# `enable-node-selector-labels: true` — status: "FromNodes/ToNodes rules can
|
||||
# only be applied when the \"enable-node-selector-labels\" flag is set". Rather
|
||||
# than change a cluster-wide Cilium flag for one policy, this uses the
|
||||
# `remote-node` entity: any cluster node, TCP 3900 only. Every cluster node is
|
||||
# on the WireGuard overlay, so this still cannot reach the LAN or the public
|
||||
# internet, and the port scope is what makes the denial test meaningful.
|
||||
#
|
||||
# Scope: Egress only, one pod selector. Other pods in siriusdevops (and every
|
||||
# other namespace) remain unrestricted — this proves the pattern, it is not
|
||||
# namespace segregation. Ingress is untouched: the Cilium Gateway must still be
|
||||
# able to reach nginx on :80.
|
||||
#
|
||||
# The policy is a whitelist: once it selects a pod, ALL egress from that pod is
|
||||
# denied except what is listed. Two allowances:
|
||||
# 1. TCP 3900 to a cluster node — Garage's S3 API on 10.10.0.1. Deliberately
|
||||
# port-scoped: 10.10.0.1 also serves the container registry on 5000, and
|
||||
# that stays unreachable from this pod.
|
||||
# 2. Cluster DNS. Nothing in this pod resolves names today (the S3 endpoint
|
||||
# is a literal IP); the rule costs one line and removes the trap of
|
||||
# breaking name resolution in a pod that later grows a container.
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: siriusdevops-site-egress
|
||||
namespace: siriusdevops
|
||||
spec:
|
||||
endpointSelector:
|
||||
matchLabels:
|
||||
app: siriusdevops-site
|
||||
egress:
|
||||
# Garage S3 API, on a WireGuard-overlay node, port 3900 only.
|
||||
- toEntities:
|
||||
- remote-node
|
||||
toPorts:
|
||||
- ports:
|
||||
- port: "3900"
|
||||
protocol: TCP
|
||||
|
||||
# Cluster DNS (CoreDNS) only.
|
||||
- toEndpoints:
|
||||
- matchLabels:
|
||||
io.kubernetes.pod.namespace: kube-system
|
||||
k8s-app: kube-dns
|
||||
toPorts:
|
||||
- ports:
|
||||
- port: "53"
|
||||
protocol: UDP
|
||||
- port: "53"
|
||||
protocol: TCP
|
||||
88
apps/base/siriusdevops/networkpolicy.yaml
Normal file
88
apps/base/siriusdevops/networkpolicy.yaml
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
# Tenant isolation for `siriusdevops` (audit finding F3 / A5-1, card t_fed52919).
|
||||
#
|
||||
# Replaces the egress-only `siriusdevops-site-egress` CiliumNetworkPolicy. That
|
||||
# policy proved the mechanism but restricted one pod in one direction; this file
|
||||
# adds the namespace-wide deny and keeps the two allow rules that measurement
|
||||
# established:
|
||||
#
|
||||
# WHY THE GARAGE RULE IS `remote-node` AND NOT `ipBlock`:
|
||||
# 10.10.0.1 is a CLUSTER NODE (rpi, the WireGuard hub), not a bare address.
|
||||
# Cilium resolves it to `reserved:remote-node` (identity 6) in its ipcache
|
||||
# (`cilium-dbg bpf ipcache list | grep 10.10.0.1` -> identity=6), and
|
||||
# `ipBlock`/toCIDR rules are only evaluated for `reserved:world`. A standard
|
||||
# NetworkPolicy with `ipBlock: 10.10.0.1/32` is silently inert here — measured:
|
||||
# the pod's request to 10.10.0.1:3900 timed out exactly like the denied ports,
|
||||
# while Prometheus (unrestricted namespace) scraped the same host fine.
|
||||
# `toNodes` would name the node exactly but needs Cilium's
|
||||
# `enable-node-selector-labels` flag; the port-scoped `remote-node` entity gives
|
||||
# the same reach (any cluster node is on the WireGuard overlay, TCP 3900 only)
|
||||
# without a cluster-wide flag change.
|
||||
#
|
||||
# `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the
|
||||
# deny. `siriusdevops-allow` (CiliumNetworkPolicy) re-adds:
|
||||
# ingress: Cilium Gateway proxy (`reserved:ingress`) for siriusdevops.com ->
|
||||
# site:80 / contact:8090, plus node/health entities for kubelet probes.
|
||||
# egress: cluster DNS; its own pods; `world` for the Telegram Bot API used by
|
||||
# siriusdevops-contact; node IPs on 3900 for the media pull the site
|
||||
# runs in its initContainer (Garage S3, http://10.10.0.1:3900).
|
||||
#
|
||||
# Port 5000 (the container registry on the same node) stays unreachable from
|
||||
# these pods, exactly as before.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny
|
||||
namespace: siriusdevops
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
---
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: siriusdevops-allow
|
||||
namespace: siriusdevops
|
||||
spec:
|
||||
description: >-
|
||||
siriusdevops: gateway + kubelet ingress; egress to own namespace, cluster
|
||||
DNS, the internet and Garage on node IPs (TCP 3900) 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: siriusdevops
|
||||
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: siriusdevops
|
||||
# Telegram Bot API (contact form delivery).
|
||||
- toEntities:
|
||||
- world
|
||||
# Garage S3 API, on a WireGuard-overlay node, port 3900 only.
|
||||
- toEntities:
|
||||
- remote-node
|
||||
toPorts:
|
||||
- ports:
|
||||
- port: "3900"
|
||||
protocol: TCP
|
||||
Loading…
Reference in a new issue