/인프라/K8s Communication Error Guide: 3-Step Troubleshooting from CNI to Service Mesh
Infrastructure쿠버네티스 네트워킹k8s 트러블슈팅

K8s Communication Error Guide: 3-Step Troubleshooting from CNI to Service Mesh

A complete guide for when you hit Kubernetes networking issues such as Pod-to-Pod communication failures and Service discovery errors. It walks through a systematic 3-step troubleshooting roadmap—from CNI diagnostics through NetworkPolicy a

K8s Communication Error Guide: 3-Step Troubleshooting from CNI to Service Mesh

A Complete Guide to Solving Kubernetes Networking Problems: Step-by-Step Troubleshooting from CNI to Service Mesh

Kubernetes is a cornerstone of modern cloud-native architecture. Thanks to the power of container orchestration, countless developers and infrastructure engineers rely on this platform. Behind that power, however, lies a maze-like networking stack. Questions like “Why can’t Pod A talk to Pod B?” and “The Service IP looks fine—why isn’t traffic actually flowing?” are walls every infrastructure engineer hits at some point.

Kubernetes networking is more than simple routing. IP allocation, service discovery, and policy-based access control (policy enforcement) are all intertwined, so when something breaks it is easy to feel lost about where to start. This guide gives you a practical troubleshooting roadmap so you can systematically narrow down the cause instead of getting stuck.

1. Why Is Kubernetes Networking So Complex? Revisiting the Fundamentals

Understanding the basic communication flow in a Kubernetes environment is the starting point for every fix. Think in terms of L3 (IP-based routing) and L4 (port-based communication), with a service abstraction layer sitting on top.

Understanding the Difference Between Pod IP and Service IP

The most common source of confusion is the difference between Pod IP and Service IP.

  • Pod IP: Each Pod has a unique real IP address within the cluster, similar to an address assigned to a physical network interface.
  • Service IP: A Service is a virtual, stable endpoint. This IP is not a real Pod IP; it is a fixed logical address used to reach the service. Internally, Kubernetes uses kube-proxy to load-balance traffic arriving at the Service IP across the currently healthy Pod IPs.

💡 Practitioner experience: The mistake I run into most often is assuming everything is fine because the Service IP looks healthy, then calling Pod IPs directly. If you skip the Service and hit a Pod IP, communication breaks as soon as that Pod scales out (and its IP changes) or goes down. Always go through the Service abstraction.

The Role of CNI: Understanding Overlay Networks

CNI (Container Network Interface) is the actual communication bridge that enables Pod-to-Pod traffic across Kubernetes nodes. Without CNI, Pods on different nodes have no way to reach each other’s IP addresses.

CNIPrimary mechanismTroubleshooting focus
FlannelVXLAN-based overlay (simplest)Overlay tunneling misconfiguration, path restrictions
CalicoBGP-based routing (native routing oriented)BGP peering issues, missing routes
CiliumeBPF-based (kernel-level packet processing)eBPF map load failures, kernel version compatibility

If communication fails, first ask whether the CNI has correctly built the inter-node routing tables.

2. Step-by-Step Troubleshooting Checklist: What to Check When Communication Fails

When a networking problem appears, this order is the most efficient.

🟢 Step 1: Pod-level checks (lowest layer)

First, confirm that the two Pods you care about can actually talk to each other.

  1. Check IP addresses: Confirm both Pods’ IPs and that those IPs are actually assigned.
    Bash
    kubectl get pods --all-namespaces -o wide
  2. Test connectivity: Try direct communication with ping or nc (netcat).
    Bash
    # 예시: Pod A에서 Pod B의 IP로 핑 테스트
    kubectl exec -it <Pod_A_Name> -- ping <Pod_B_IP>
  3. Node-level check: If Pod-to-Pod communication fails, verify routing at the node level (SSH onto the node).
    Bash
    ip route show
    # Pod IP 대역으로의 경로가 정상적으로 설정되어 있는지 확인

🟡 Step 2: Service-level checks (abstraction layer)

If Pods can talk to each other but service calls still fail, suspect the Service definition or kube-proxy.

  1. Review the Service definition: Confirm the selector exactly matches the Pod labels.
    YAML
    # YAML 확인: selector: app=backend 이 실제 Pod의 label app=backend 와 일치해야 함
  2. Check Endpoints: Inspect the actual endpoint list the Service is targeting.
    Bash
    kubectl get endpoints <service-name> -n <namespace>
    If the <service-name>: <IP:Port> list is empty, the Service is not matching any Pods.

🔴 Step 3: Policy and boundary checks (highest layer)

If the first two steps look healthy, an external policy or firewall is likely dropping traffic.

  1. Review NetworkPolicy: This is the most common cause. If an explicit NetworkPolicy is applied to a namespace or Pod, any traffic outside the allowed ports and sources/destinations is dropped.
    • Check: List policies with kubectl get netpol -n <namespace> and inspect Ingress and Egress rules.
  2. CNI network policy: Confirm whether the CNI in use (Calico, Cilium, etc.) is enforcing additional network policies.

🚀 Deep dive: Approaches by troubleshooting scenario

SymptomLikely causeHow to fix
"Connection Refused"1. The service is down. 2. The port is not listening.Check kubectl get pods. Confirm the port is listening with netstat or ss.
"Timeout"1. Blocked by a firewall (Security Group/NetworkPolicy). 2. Routing problem.Use network flow analysis tools. Review CNI policies.
"No Route to Host"1. Service IP is routed incorrectly. 2. Service Mesh misconfiguration.Check the routing table between the Service IP and actual Pod IPs.

With this guide, you should be able to systematically diagnose and resolve infrastructure-level networking issues—not just application bugs.

References: Official docs

The primary source for the behavior, configuration, and errors covered in this article is the following official documentation. Check it for version-specific options and exact behavior.

확인 정보
✦ ✦ ✦
편집 검토 · Editorial Review

Nodelog는 모든 콘텐츠의 내용과 출처를 공개 전에 검토합니다. 환경(OS·버전)에 따라 결과가 달라질 수 있는 기술 정보는 공식 문서와 함께 확인하며, 검토 기준과 정정 원칙은 편집 정책에서 안내합니다. 오류를 발견하시면 이메일로 제보해 주세요 — 확인 후 신속히 정정합니다.

편집 책임 · Nodelog 기술 편집팀·발행 · ·업데이트 ·

Comments

Be the first to comment.