CKS mastery journey · Fresh transfer
Two-sided NetworkPolicy isolation
Secure current and future workloads while composing namespace, Pod, port, DNS, and CIDR restrictions without unintended additive access.
Scenario
kubectl config use-context secure-prod
| Pod | Labels | Listens on |
|---|---|---|
web-0 | app=web | TCP 443 |
api-0 | app=api | TCP 8080 |
batch-0 | app=batch | none |
edge is labeled zone=trusted-edge; approved clients are role=proxy. monitoring is labeled purpose=metrics; approved clients are role=scraper.
DNS Pods are in kube-system with k8s-app=kube-dns. Database CIDR is 10.40.0.0/16; 10.40.8.0/24 is forbidden. Future unlabeled Pods may appear in blue.
Required end state
- Default-deny ingress and egress for every current and future Pod in
blue. - Trusted edge proxies alone may reach
webon TCP 443. - Only
webmay reachapion TCP 8080. - Approved monitoring scrapers may reach
webandapion TCP 9100. - Only
webandapimay query cluster DNS over UDP/TCP 53. - Only
apimay reach the database CIDR on TCP 5432, excluding its reserved subnet. batchhas no traffic; no other traffic is permitted.- Do not modify existing objects or use CNI-specific policy kinds.