Marcio Cunha

How to monitor pod network latency in Kubernetes with eBPF

Learn how to monitor network latency between Kubernetes pods in real time using eBPF, Cilium, and Hubble without modifying your applications.

Marcio Cunha•4 min
Also available in:EspañolPortuguês
Summary
  • Using eBPF allows inspecting network traffic directly inside the operating system kernel without altering running applications
  • Modern tools like Cilium and Hubble replace traditional iptables with optimized routing and deep observability
  • Measuring end-to-end latency reveals invisible bottlenecks caused by network congestion or internal thread queues
  • Proper network policy configuration complements visibility and ensures security without penalizing overall performance
  • Accurate diagnostics prevent blind debugging efforts and drastically reduce the mean time to resolution for incidents

Why Kubernetes network latency is hard to measure

When applications talk inside a Kubernetes cluster, data packets travel through complex virtual networks. Finding out where delays happen is often a frustrating challenge for engineering teams. In many scenarios, troubleshooting issues akin to resolving node synchronization bottlenecks requires tools that go far beyond traditional ping commands. The operating system handles dozens of abstraction layers, iptables, and virtual bridges before a packet reaches its final destination.

Traditional monitoring tools frequently require modifying application code to inject tracing headers. This consumes precious time and is rarely feasible in legacy environments or third-party software. Slowness can creep in silently between microservices, triggering hard-to-reproduce timeouts and frustrating end users who notice the application hanging for no apparent reason.

What is eBPF and how it revolutionizes observability

eBPF (Extended Berkeley Packet Filter) is a revolutionary technology built into the Linux kernel that allows running safe programs directly inside the core of the operating system. Think of it as a small, highly specialized robot that watches everything happening on the network without disrupting the machine's normal operation. Before eBPF, deep inspection required modifying the kernel or installing unstable modules that could crash entire servers.

In practice, this means we can intercept system calls and network events with minimal performance impact. The kernel executes these small scripts in an isolated and secure manner, ensuring no malicious or flawed code compromises cluster stability. This approach transforms how we diagnose failures and investigate blocked traffic between containers, delivering real-time metrics with virtually zero overhead.

Cilium and Hubble: Kubernetes eyes at the kernel level

Cilium is a Kubernetes networking plugin built entirely on top of eBPF technology. It replaces the traditional iptables-based rule model with a highly efficient mechanism driven by BPF maps. While Cilium handles traffic at impressive speeds, Hubble acts as the observability interface, gathering detailed data about network flows, dropped connections, and latency between specific pods.

With Hubble, you can visualize an interactive dependency map between services and measure exactly how long each request takes to process. If a payment microservice takes longer than expected to reply to the main API, Hubble pinpoints the delay down to the millisecond. This granular visibility eliminates guesswork and guides operators directly to the root cause of performance issues.

How to implement latency collection step by step

To start collecting latency metrics with Cilium and Hubble in your cluster, you must ensure your node's kernel is compatible (version 5.4 or higher recommended). Installation is typically performed via Helm, the official package manager for the Kubernetes ecosystem. Follow the steps below to set up the basic monitoring environment.

First, add the official Cilium repository to your Helm package manager by running the following command in your workstation terminal:

helm repo add cilium https://helm.cilium.io/

Next, update your local repository list to make sure you download the latest and most stable version of the software:

helm repo update

Finally, install Cilium while explicitly enabling the Hubble component and its network flow metrics with the following deployment command:

helm install cilium cilium/cilium --namespace kube-system --set hubble.enabled=true --set hubble.relay.enabled=true --set hubble.ui.enabled=true

Analyzing metrics and identifying real bottlenecks

With Hubble UI or the command-line interface enabled, you can observe data flows in real time. Collected metrics include TCP response time, connection latency, and packet loss rates across namespaces. Establishing baselines for your environment is essential, as what is considered high latency for an internal API might be completely normal for a batch processing pipeline.

Often, latency spikes are unrelated to the network itself, but rather to CPU bottlenecks on nodes hosting the pods. When Kubernetes automatic scaling places too many heavy pods on the same physical server, resource contention affects network packet processing. Correlating Hubble latency metrics with alerting tools, such as centralizing infrastructure logs and metrics, helps identify whether the issue stems from hardware, network configuration, or inefficient code.

Conclusion

Monitoring network latency in Kubernetes environments has shifted from an operational luxury to a core requirement for guaranteeing modern system reliability. The combined use of eBPF, Cilium, and Hubble offers a transparent window into kernel behavior without sacrificing security or demanding code rewrites. By adopting these tools, your team gains the ability to diagnose complex issues in seconds, turning mysterious outages into clear, actionable data.