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

Pods cannot reach anything on the internet (`curl https://github.com` times out), while in-cluster traffic works.

IntermediateTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer

Likely causes → No egress path: private subnets with no NAT gateway or a broken route table, an egress NetworkPolicy, a corporate proxy required, or on EKS the VPC CNI's SNAT disabled (AWS_VPC_K8S_CNI_EXTERNALSNAT=true) without a NAT.

Diagnose →

kubectl run nettest --rm -it --image=nicolaka/netshoot --restart=Never -- bash -c 'nslookup github.com; curl -sv --max-time 5 https://github.com -o /dev/null'
kubectl debug node/<node> -it --image=nicolaka/netshoot -- curl -s --max-time 5 https://github.com -o /dev/null -w '%{http_code}\n'
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=<subnet>

If the node works but the Pod does not, it is SNAT or NetworkPolicy; if both fail, it is routing/NAT.

Fix → Add the NAT route or fix SNAT settings; allow egress in NetworkPolicy; set HTTPS_PROXY/NO_PROXY (include .svc,.cluster.local,10.0.0.0/8) if a proxy is mandatory.

Prevent → VPC endpoints for AWS services, egress tests in cluster bootstrap.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, DNS, Ingress and NetworkPolicy