CertGrid CertGrid
Hands-on Lab·Certified Kubernetes Application Developer

NetworkPolicy Egress and DNS

A default-deny egress policy blocks port 53 along with everything else, so DNS stops working and every symptom points at DNS rather than at the policy you just wrote. Worse, adding an explicit allow rule for the service you wanted does not fix it, because the client still cannot resolve the name. This reproduces the whole sequence and then fixes it properly.

Services and Networking Guide 37 of 44 Intermediate

Written against the versions above. NetworkPolicies are enforced by the CNI plugin. This cluster runs Calico; on a cluster whose CNI does not implement them - plain flannel, for instance - every policy here is accepted by the API server and enforces nothing at all, which is a far more dangerous failure than the one this guide is about.

Calico enforces the policies. The client and the backend may land on different nodes; the policy applies either way.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

Before you start

  1. Two Pods that can talk

  2. Deny all egress

  3. Allowing the API does not help

  4. The DNS exception every egress policy needs

Official sources