abyss-o5mtsz runs the whole market, wide open: anything can reach the database, and nothing is published to the outside. Close it, then open the right doors.
sh
kubectl get pods,svc -n abyss-o5mtsz -o wide
kubectl get netpol,ingress -n abyss-o5mtszInside: default deny, then allow
- A policy
default-denythat isolates every Pod in the namespace for ingress and egress. market-dbaccepts connections only frommarket-api, on 5432.market-apiaccepts connections only frommarket-weband from the ingress controller, on 8080. The controller runs inkube-system; anamespaceSelectoron that namespace is the usual way to allow it.market-webaccepts connections from anywhere on 80.- Everything selected needs DNS back: an egress policy
allow-dnsfor all Pods, UDP 53 tokube-system, plus whatever egress each tier needs: web to api on 8080, api to db on 5432.
Test as you go from the client Pod and from the Pods themselves:
sh
kubectl exec client -n abyss-o5mtsz -- nc -zv -w 1 market-db 5432
kubectl exec deploy/market-web -n abyss-o5mtsz -- wget -qO- -T 1 market-api:8080/healthzOutside: one hostname
- An Ingress
marketon classtraefikfor hostmarket.example:/monsters(Prefix) tomarket-api:8080, everything else tomarket-web:80.
sh
curl -s -H "Host: market.example" http://10.0.0.10/
curl -s -H "Host: market.example" http://10.0.0.10/monstersThe last call only works once the API's ingress policy lets the controller in. The final objective asks which status the controller returns when a rule matches but the Service has no endpoints.