63 lines
2.1 KiB
YAML
63 lines
2.1 KiB
YAML
|
|
# 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
|