Someone applied a default-deny NetworkPolicy in `prod`; now every pod fails to call other services with "getaddrinfo ENOTFOUND orders" even though the allow rules look right.
BeginnerTroubleshootingKubernetes cluster-level
Answer
Likely causes → The default-deny blocks egress too, including DNS to CoreDNS in kube-system. Your allow rules permit traffic to the service, but the name can't be resolved first.
Diagnose →
kubectl get networkpolicy -n prod
kubectl exec deploy/api -n prod -- nslookup orders
kubectl exec deploy/api -n prod -- nc -vz 10.96.0.10 53
Fix → Add an egress rule allowing DNS:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: allow-dns, namespace: prod }
spec:
podSelector: {}
policyTypes: [Egress]
egress:
- to:
- namespaceSelector:
matchLabels: { kubernetes.io/metadata.name: kube-system }
podSelector:
matchLabels: { k8s-app: kube-dns }
ports:
- { protocol: UDP, port: 53 }
- { protocol: TCP, port: 53 }
Prevent → Ship default-deny and allow-DNS together as one bundle, and test policies in staging with a connectivity check.
More on Kubernetes cluster-level
Every `kubectl` command fails with "The connection to the server 10.0.1.10:6443 was refused - did you specify the right host or port?"BeginnerA new deployment's pods stay Pending with "0/5 nodes are available: 5 Insufficient cpu. preemption: 0/5 nodes are available: 5 No preemption victims found for incoming pod."BeginnerPods are Pending, but Cluster Autoscaler won't add nodes; the pod events say "pod didn't trigger scale-up: 2 node(s) didn't match Pod's node affinity/selector, 1 max node group size reached".IntermediateA node goes NotReady and kubelet logs "PLEG is not healthy: pleg was last seen active 3m10s ago; threshold is 3m0s".IntermediateAfter a node was terminated, its pods have shown `Terminating` for two hours and their replacements aren't being created.IntermediateYou deleted a namespace an hour ago and it's still `Terminating`.Intermediate