Skip to main content

Debugging Kubernetes Pod Networking

Diagnose Kubernetes pod networking failures layer by layer, from CNI and kube-proxy to CoreDNS and NetworkPolicies, using kubectl and netshoot.

52 Terms

Overview and What You Will Learn

Debug Kubernetes networking by testing one layer at a time, starting from the pod's own network interface and moving up to Services, DNS and policy, so you find the broken layer instead of guessing. A pod can be Running and healthy while a CNI fault, an empty Service, a DNS failure or a NetworkPolicy keeps it from talking to anything. In this lab you will use a netshoot debug container and kubectl to isolate each kind of failure.

  • Attaching a netshoot debug container to a pod's network namespace
  • Diagnosing pods stuck in ContainerCreating because the CNI failed
  • Testing pod-to-pod traffic across nodes
  • Checking Service endpoints and kube-proxy rules
  • Diagnosing CoreDNS and name resolution failures
  • Spotting NetworkPolicy drops

Why This Matters in Production

Networking failures are hard to diagnose because the application only reports a timeout or a refused connection. Imagine an order service that calls a risk service and silently falls back to cached data when the call times out. Nothing in the application logs says whether the break is in the CNI, the Service, DNS or a policy, so the team loses hours unless they have a systematic method that proves each layer works before moving to the next.

Core Principles

Five layers can fail independently, and you test them in order, because a fault at a lower layer makes every higher test fail too. The first three tests are about reachability, and DNS and policy are checked once those pass or when the symptoms point to them.

flowchart TD A{Pod Running
with an IP?}:::q -->|no| L1[CNI setup failing]:::bad A -->|yes| B{Reach a pod
on another node?}:::q B -->|no| L2[CNI overlay or policy]:::bad B -->|yes| C{Reach the
Service ClusterIP?}:::q C -->|no| L3[Endpoints or kube-proxy]:::bad C -->|yes| D[Check DNS and
NetworkPolicy]:::ok classDef q fill:#FFEDD5,color:#1E293B classDef bad fill:#EF4444,color:#FFFFFF classDef ok fill:#10B981,color:#FFFFFF
Layer Typical symptom First tool
1. Pod interface and CNI setup Pod stuck in ContainerCreating with no IP kubectl describe pod
2. CNI overlay between nodes Pod has an IP but cannot reach pods on other nodes CNI pod logs, ping, curl
3. Service routing (endpoints, kube-proxy) Pod IP works but the Service IP fails kubectl get endpointslices
4. DNS (CoreDNS) Service IP works but the name fails nslookup, CoreDNS logs
5. NetworkPolicy Timeouts only for some sources or namespaces kubectl get networkpolicy, Hubble

A refused connection and a timeout mean different things. A refusal means a packet reached a host that has no listener or a rule that rejects it, and a timeout usually means a packet was dropped on the way.

Detailed Step-by-Step Practical Lab

Step 1 - Attach a netshoot Debug Container

netshoot is a container full of network tools, including curl, dig, nslookup, tcpdump and traceroute. Start a standalone debug pod in the same namespace as the failing service:

Bash
kubectl run netshoot --image=nicolaka/netshoot -it --rm -n production -- bash

To see the network exactly as an application pod sees it, attach an ephemeral container to that pod. An ephemeral container always shares the pod's network namespace, so it has the same IP, routes and DNS settings. The --target option names an application container and additionally shares its process namespace:

Bash
kubectl debug -it order-service-7d9f8b-xkp2q -n production \
--image=nicolaka/netshoot \
--target=order-service \
-- bash
Remember

Test from inside the pod's network namespace, not from your laptop. Only a container in the same namespace shows what the application experiences, including its DNS settings and any policy that applies to it.

Step 2 - Layer 1: Does the Pod Have a Network Interface and IP?
Bash
kubectl get pod order-service-7d9f8b-xkp2q -n production -o wide
# order-service-7d9f8b-xkp2q 0/1 ContainerCreating <none> mumbai-worker-1
kubectl describe pod order-service-7d9f8b-xkp2q -n production
# Look in Events for messages such as:
# Failed to create pod sandbox: ... failed to set up sandbox container network ...
# failed to assign an IP address to container

A pod with no IP means the CNI failed during sandbox setup. Common causes are a CNI pod that is not running on that node, a missing or broken file in /etc/cni/net.d/ on the node, or an exhausted IP pool, which is typical when a cloud CNI runs out of addresses on a small subnet. Check the node and the CNI DaemonSet:

Bash
kubectl get nodes
kubectl get pods -n kube-system -o wide | grep -E "calico|cilium|flannel|aws-node"
kubectl logs -n kube-system CNI-POD-NAME --tail=50

If the pod started, check its interface and routes from inside:

Bash
ip addr show eth0
ip route show
Step 3 - Layer 2: Test Pod-to-Pod Traffic Across Nodes

Pick two pods on different nodes and test from a netshoot container in the first:

Bash
kubectl get pods -n production -o wide | grep order-service
# order-service-7d9f8b-xkp2q 10.244.2.15 mumbai-worker-1
# order-service-7d9f8b-mn3lp 10.244.3.22 mumbai-worker-2
# Inside netshoot: test by IP, with TCP as well as ping, since ICMP is often filtered
ping -c 3 10.244.3.22
curl -sS -m 3 http://10.244.3.22:8080/health

If pods on the same node reach each other but pods on different nodes do not, suspect the overlay. Frequent causes are a cloud firewall or security group that blocks the CNI's tunnel traffic (VXLAN uses UDP 4789, and IP-in-IP uses IP protocol 4), an MTU mismatch, or a CNI agent that is unhealthy on one node. Check the CNI on both nodes:

Bash
kubectl get pods -n kube-system -o wide | grep -E "calico|cilium"
kubectl logs -n kube-system CNI-POD-ON-FAILING-NODE --tail=100
# Cilium: overall health and an end-to-end test
cilium status
cilium connectivity test

For Calico, check BGP or overlay status with calicoctl node status run on the node, if calicoctl is installed there.

Step 4 - Layer 3: Test the Service and Its Endpoints

Test the pod IP directly, then the Service IP. A ClusterIP is virtual and answers only on its ports, so test with curl, not ping:

Bash
# Direct pod IP bypasses Service routing
curl -sS -m 3 http://10.244.2.15:8080/health
# The Service ClusterIP goes through kube-proxy rules
kubectl get service order-service -n production
curl -sS -m 3 http://10.96.45.200:8080/health

If the pod IP works and the Service IP fails, check whether the Service has backends. Modern clusters store them in EndpointSlices, and the older Endpoints API is deprecated:

Bash
kubectl get endpointslices -n production -l kubernetes.io/service-name=order-service
kubectl get endpoints order-service -n production
# ENDPOINTS shows <none> or an empty list when nothing matches the selector

Empty endpoints usually mean one of three things. The Service selector does not match the pod labels, the pods are not Ready (a failing readiness probe removes them), or the Service targetPort is wrong. Compare the selector with the labels:

Bash
kubectl get service order-service -n production -o jsonpath='{.spec.selector}'
kubectl get pods -n production --show-labels | grep order-service
# app=orders-service in the pod versus app=order-service in the Service: a typo

A Service with no endpoints makes kube-proxy reject connections, so you see "Connection refused" instead of a timeout. If endpoints are correct and the ClusterIP still fails, check that kube-proxy ran and programmed rules on the node. The exact command depends on the proxy mode:

Bash
kubectl get pods -n kube-system -l k8s-app=kube-proxy
kubectl logs -n kube-system KUBE-PROXY-POD | grep -i error
# On the node, for iptables mode
sudo iptables -t nat -L KUBE-SERVICES -n | grep 10.96.45.200

Some clusters, such as Cilium with kube-proxy replacement, do not run kube-proxy at all, and others use IPVS or nftables mode, so check which mode your cluster uses first.

Tip

Restarting the kube-proxy pod on one node forces a rules resync and can fix stale rules, but do it only after you have confirmed the endpoints are correct, so you are not hiding the real cause.

Step 5 - Layer 4: Diagnose DNS

Test names step by step from netshoot:

Bash
# 1. The short name resolves only inside the same namespace
nslookup order-service
# 2. The fully qualified name works from any namespace
nslookup order-service.production.svc.cluster.local
# 3. Read the pod's DNS settings
cat /etc/resolv.conf
# nameserver 10.96.0.10
# search production.svc.cluster.local svc.cluster.local cluster.local
# options ndots:5
# 4. Is external resolution broken too?
nslookup example.com

If short names fail but the fully qualified name works, the pod is probably in a different namespace than the Service. If the Service name works but external names fail with SERVFAIL, CoreDNS cannot reach its upstream resolver. Check CoreDNS:

Bash
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=100
kubectl get endpointslices -n kube-system -l kubernetes.io/service-name=kube-dns
kubectl get configmap coredns -n kube-system -o yaml

By default CoreDNS forwards external queries to the node's resolver (forward . /etc/resolv.conf). If the nodes cannot reach their resolver, or a firewall blocks it, change the forward line to a resolver your network allows, such as the VPC or datacenter resolver, rather than a public one your organization may prohibit:

Bash
kubectl edit configmap coredns -n kube-system
# Change the forward line, for example: forward . 10.0.0.2
kubectl rollout restart deployment/coredns -n kube-system

Also check that NetworkPolicies are not blocking DNS. A default-deny egress policy without a DNS rule is one of the most common causes of cluster-wide name failures in a single namespace.

Step 6 - Layer 5: Look for NetworkPolicy Drops
Bash
kubectl get networkpolicy -n production -o wide
kubectl describe networkpolicy POLICY-NAME -n production

The classic symptom is that a pod IP works from one namespace and times out from another. Both the client's egress policy and the server's ingress policy must allow the connection. On Cilium, Hubble shows dropped packets and the reason:

Bash
hubble observe --namespace production --verdict DROPPED --last 100

On Calico, review the policies with calicoctl get networkpolicy -o wide and check its flow logs if enabled. Plain Kubernetes gives no log of policy drops, which is why a flow-observability tool is worth having.

Security

The first NetworkPolicy you add to a namespace can instantly cut off every flow you did not list. Add allow rules for each legitimate path, including DNS and monitoring, in the same change.

Step 7 - Run a Connectivity Matrix

Check every important path in one run, so you can compare results before and after a change:

Bash
kubectl run connectivity-test --image=nicolaka/netshoot -n production \
--restart=Never -- sh -c '
for url in http://order-service:8080/health \
http://payments-service.payments-production.svc.cluster.local:4000/health; do
code=$(curl -s -m 3 -o /dev/null -w "%{http_code}" "$url")
echo "$url -> $code"
done
nslookup example.com > /dev/null && echo "external DNS ok" || echo "external DNS FAILED"
'
kubectl logs connectivity-test -n production
kubectl delete pod connectivity-test -n production

Production Best Practices & Common Pitfalls

Common Mistake

Diagnosing a network problem from application logs. They report "timeout" or "connection refused" and cannot tell you which layer failed. Use a debug container in the pod's network namespace and test each layer in order.

Tip

Keep a netshoot image mirrored in your own registry, and know how your cluster allows kubectl debug. In a real incident you do not want to wait on an image pull or a missing permission.

Remember

Debug from the bottom up. If a pod has no IP, DNS tests are meaningless, and if the pod IP is unreachable, the Service and DNS cannot work.

  • Use Hubble or an equivalent on production clusters. Policy debugging without drop visibility is guesswork, and the visibility pays for itself on the first incident.
  • Alert on CoreDNS SERVFAIL responses. Watch coredns_dns_responses_total with the rcode="SERVFAIL" label, since a spike points at an upstream DNS failure that breaks service discovery across the cluster.
  • Label namespaces predictably. Rely on the automatic kubernetes.io/metadata.name label for namespace selectors.
  • Check node and CNI health before blaming the app. A single unhealthy CNI agent breaks only the pods on its node, which looks like a flaky service.
  • Treat packet capture as a controlled action. Running tcpdump on a production node can expose sensitive traffic, so follow your organization's approval and logging process.

Quick Reference & Troubleshooting Commands

Command Description
kubectl run netshoot --image=nicolaka/netshoot -it --rm -n NS -- bash Start a standalone network debug pod
kubectl debug -it POD --image=nicolaka/netshoot --target=CONTAINER -n NS -- bash Attach a debug container to a pod's network
kubectl get endpointslices -n NS -l kubernetes.io/service-name=SVC Check a Service's backends
kubectl get networkpolicy -n NS -o wide List policies in a namespace
kubectl get pods -n kube-system -l k8s-app=kube-dns Check CoreDNS pod health
kubectl logs -n kube-system -l k8s-app=kube-dns Read CoreDNS logs
nslookup SVC.NS.svc.cluster.local Test DNS from inside a pod
curl -sS -m 3 http://CLUSTERIP:PORT/path Test a Service IP and bypass DNS
kubectl get pods -n NS -o wide Show pod IPs and their nodes
hubble observe --verdict DROPPED Show packets dropped by policy on Cilium

Resources

Velero vs etcd Snapshot: Which Do You Need?

Velero vs etcd Snapshot: Which Do You Need?

Velero and etcd snapshots protect different layers of a Kubernetes cluster. See what each backs up, what each misses, and why most DR needs both.

11 min read•Aug 2026
Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient cuts the sidecar tax at L4, but L7 adds waypoint hops, and Linkerd stable builds now come from Buoyant. Choose with tests.

11 min read•Aug 2026
Nginx Ingress vs Traefik vs Gateway API in 2026

Nginx Ingress vs Traefik vs Gateway API in 2026

Ingress-NGINX is retired. Compare Traefik and Gateway API controllers as replacements, plus a safe migration plan that avoids outages.

10 min read•Aug 2026
OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno compared for 2026: Rego vs YAML, mutation, reporting, and operations, plus how to pick a Kubernetes policy engine.

10 min read•Aug 2026
Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize compared for 2026 - templating vs patching, Helm 4's new features, and why most production teams end up running both.

5 min read•Aug 2026
Prometheus vs Datadog vs New Relic: Real Costs

Prometheus vs Datadog vs New Relic: Real Costs

Prometheus, Datadog, and New Relic compared for 2026 - real pricing at scale, hidden cost drivers, and which fits a Kubernetes-heavy stack.

5 min read•Aug 2026
Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter on EKS: scale-up speed, bin-packing, Spot handling, Auto Mode limits and a safe migration path, with v1 NodePool YAML.

11 min read•Aug 2026
GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE, EKS, and AKS compared for 2026 - control plane pricing, Autopilot vs Karpenter vs Node Auto Provisioning, and which platform actually fits your team.

5 min read•Aug 2026
K3s vs K8s vs MicroK8s: Which Distro in 2026?

K3s vs K8s vs MicroK8s: Which Distro in 2026?

Compare K3s, upstream Kubernetes and MicroK8s on footprint, datastores, HA and updates, and pick the right fit for edge, dev or production.

10 min read•Aug 2026
Canary Deployments with Argo Rollouts & Flagger

Canary Deployments with Argo Rollouts & Flagger

Ship to 5% of users first and auto-rollback on bad metrics: canary deployments on Kubernetes with Argo Rollouts, Flagger, and Gateway API.

11 min read•Jun 2026
OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry in practice: instrument a Node.js service, run a production Collector, sample traces and link metrics, logs and traces in Grafana.

11 min read•Jun 2026
Kubernetes Cost Optimization Without SLO Risk

Kubernetes Cost Optimization Without SLO Risk

Kubernetes clusters average about 8% CPU use. Cut waste safely with request rightsizing, autoscaling, spot, and OpenCost, keeping SLOs.

11 min read•Jun 2026
ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD compared for 2026: UI, multi-tenancy, Helm, image automation and pruning risks, with a clear guide to picking your GitOps engine.

10 min read•Jun 2026

Explore More in Kubernetes Networking and Traffic Management

All 6 Topics

Frequently Asked Questions

Is Debugging Kubernetes Pod Networking free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Debugging Kubernetes Pod Networking topic cover?

Diagnose Kubernetes pod networking failures layer by layer, from CNI and kube-proxy to CoreDNS and NetworkPolicies, using kubectl and netshoot.

Does Debugging Kubernetes Pod Networking include hands-on modules?

Yes - this topic has 3 attached modules for hands-on practice.

Found a mistake, an outdated step or a broken link?