惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
量子位
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
V
Visual Studio Blog
雷峰网
雷峰网
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How Does Traffic Actually Reach Your Pods? Kubernetes Ser...
Sreekanth Kuruba · 2026-06-16 · via DEV Community

Sreekanth Kuruba

Your backend Pod just crashed.

Kubernetes created a new Pod with a completely different IP address.

Yet your application didn't notice anything changed.

How?

Because applications don't talk directly to Pods.

They talk to Kubernetes Services.

A Service provides a stable virtual IP and DNS name, while kube-proxy quietly programs the networking rules that route traffic to the right Pods.

In this post, we'll go beyond the usual "Service types" explanation and look at how traffic actually reaches your Pods under the hood.


What is a Kubernetes Service?

A Service provides a stable virtual IP (ClusterIP) and DNS name for a dynamic set of Pods.

Think of it as a permanent front door for Pods that may come and go.

Key points:

  • Services provide a stable endpoint for applications.
  • Pods behind a Service can change without affecting clients.
  • Services use labels and selectors to automatically discover matching Pods.
  • The Service IP is virtual—there is no process directly listening on that IP.

Important:

A ClusterIP doesn't belong to a real network interface, and no process is directly listening on that IP.

Instead, kube-proxy programs networking rules on every node so packets sent to the ClusterIP are transparently redirected to backend Pods.


How Does a Service Find Its Pods?

Kubernetes uses labels and selectors to determine which Pods belong to a Service.

Example:

Service selector:
app=backend

Matching Pods:
app=backend

Non-matching Pods:
app=frontend

Only the matching Pods become Service endpoints and receive traffic from the Service.


Why Do We Need Services?

Imagine a Deployment with three Pods:

backend-1 → 10.244.1.5
backend-2 → 10.244.2.8
backend-3 → 10.244.3.12

If backend-2 crashes, Kubernetes creates:

backend-4 → 10.244.2.15

The old IP disappears.

Without Services, every client would need to know the new Pod IPs constantly.

Services solve this problem by giving applications a stable endpoint.


Types of Kubernetes Services

1. ClusterIP (Default)

  • Accessible only inside the cluster.
  • Used for communication between microservices.

2. NodePort

  • Exposes the application on a port of every Kubernetes node.
  • Useful for testing and simple external access.

3. LoadBalancer

  • Creates an external load balancer using your cloud provider.
  • Commonly used for production applications.

4. ExternalName

  • Maps a Service to an external DNS name using a CNAME record.
  • Useful for integrating external services.

How Services Work Under the Hood

When you create a Service:

  1. Kubernetes allocates a ClusterIP.
  2. Kubernetes creates EndpointSlices, which contain the healthy Pod IPs behind the Service.
  3. kube-proxy running on every node watches for Service and EndpointSlice changes.
  4. kube-proxy programs networking rules on the node.
  5. Traffic sent to the Service IP is automatically redirected to one of the backend Pods.

kube-proxy: The Unsung Hero

Many people think kube-proxy forwards packets itself.

It doesn't.

Its job is to configure the node's networking rules so Linux can route traffic efficiently.

kube-proxy can run in three modes:

iptables Mode

  • Most common deployment mode.
  • Uses iptables rules for load balancing and NAT.

IPVS Mode

  • Uses Linux IP Virtual Server.
  • Better scalability and performance for large clusters.

Userspace Mode

  • Legacy mode.
  • Rarely used today.

Traffic Flow Example

Client Pod
      ↓
Service (ClusterIP)
      ↓
kube-proxy Rules
      ↓
┌─────┬─────┬─────┐
Pod A Pod B Pod C

When a request is sent to a Service:

  1. The packet reaches a node.
  2. kube-proxy's rules match the Service IP and port.
  3. Destination NAT (DNAT) redirects the request to one of the healthy Pods.
  4. The Pod sends the response back to the client.

All of this happens transparently.

The client thinks it is communicating with a single stable IP.


Common Service Problems

Pods are not receiving traffic?

Check whether labels match the Service selector.

kubectl describe service <service-name>
kubectl get endpointslices

No backend Pods found?

Verify the Pods are Ready.

kubectl get pods -o wide

Debug kube-proxy Rules

ipvsadm -Ln
iptables -t nat -L KUBE-SERVICES -n


Fun Fact

Some modern networking solutions like Cilium can replace kube-proxy entirely using eBPF, reducing iptables complexity and improving observability.


Summary

Pods are temporary, and their IP addresses can change at any time.

Kubernetes Services provide a stable entry point, while kube-proxy makes the magic happen by programming networking rules on every node.

Understanding this flow helps you:

  • Debug Service connectivity issues faster
  • Choose the right Service type
  • Understand how traffic moves inside Kubernetes
  • Build more reliable Kubernetes applications

Next in the Series: CoreDNS Explained – How Kubernetes Turns Service Names into IP Addresses