Default deny for ingress and egress also blocks what nobody thinks of: the DNS query to CoreDNS. After that every connection fails at name resolution.
Symptom
kubectl apply -f default-deny-all.yaml networkpolicy.networking.k8s.io/default-deny-all created ✘ blockiert shop/frontend -> http://api.tenant-a (Timeout)
From now on the namespace shop has default deny for ingress and egress (blockiert = blocked).
Diagnosis
Check name resolution directly in the pod.
kubectl -n shop exec deploy/frontend -- nslookup api.tenant-a.svc.cluster.local ;; connection timed out; no servers could be reached command terminated with exit code 1
Causes
EgressDNS is egress
The packet to CoreDNS (10.96.0.10:53) leaves the pod – with policyTypes Egress and no egress rule it is forbidden.
Pod IPNo way out even without DNS
The cross-check with the pod IP fails too: default deny works in both directions.
cc shop/frontend http://$IP:8080 ✘ blockiert shop/frontend -> http://10.244.0.8:8080 (Timeout)
Fix
kubectl apply -f allow-dns.yaml networkpolicy.networking.k8s.io/allow-dns created Server: 10.96.0.10 Name: api.tenant-a.svc.cluster.local Address: 10.96.4.91
Don't: Deleting the default-deny policy again. It stays; DNS comes in as its own policy – NetworkPolicies are additive.
Kyverno & NetworkPolicies hands-on, Day 2: default deny, allowing DNS, service vs. container port, ipBlock and probes.
Go to day 2 →
FAQ
Why TCP 53 in addition to UDP?
Large answers (DNSSEC, many records) fall back to TCP. Without TCP 53 they fail sporadically.
Why does nslookup api.shop resolve a public IP?
Busybox nslookup ignores the search list from /etc/resolv.conf, and .shop is a real top-level domain. Always use the full name in policies and configs.