Interview Prep/Kubernetes/Services, DNS, Ingress and NetworkPolicy

A NetworkPolicy that should block traffic has no effect at all.

BeginnerTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer

Likely causes → The CNI does not enforce NetworkPolicy (Flannel alone, older kubenet, VPC CNI without network policy enabled), so the objects are accepted by the API server but ignored. Or the podSelector matches no Pods.

Diagnose →

kubectl get pods -n kube-system | grep -Ei 'calico|cilium|aws-node|flannel'
kubectl get networkpolicy deny-all -n shop -o yaml | yq '.spec.podSelector'
kubectl get pods -n shop -l <selector>

Fix → Use a policy-capable CNI (Calico, Cilium) or, on EKS, enable the VPC CNI network policy agent (enableNetworkPolicy: "true" in the add-on config).

Prevent → Cluster acceptance test: apply deny-all and assert a connection fails.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, DNS, Ingress and NetworkPolicy