Service Discovery in Mesh
You'll learn: How service meshes automatically maintain up-to-date routing information without hardcoding IP addresses or endpoints.
The Dynamic Directory Problem
In traditional networking, you might hardcode service endpoints: "The payment service is at 10.0.1.5:8080." But in Kubernetes, pods come and go constantly—scaling up, restarting, moving nodes. Hardcoded addresses break immediately.
A service mesh solves this through automatic service discovery: it continuously tracks which pods belong to which services and updates routing tables in real-time.
How It Works
Think of service discovery like a constantly updated phone directory for your cluster. Instead of memorizing phone numbers (IP addresses), you just ask for "payment service" and the mesh connects you to a healthy instance.
The control plane maintains this directory by:
- Watching the Kubernetes API for service and pod changes
- Detecting when pods start, stop, or fail health checks
- Pushing updated routing rules to every sidecar proxy in the data plane
When your application makes a request to http://payment-service, the local sidecar proxy:
- Looks up current healthy endpoints from its synchronized routing table
- Selects an instance (often with load balancing)
- Routes the request transparently
Benefits Over Traditional Discovery
Unlike DNS-based discovery (which caches entries), mesh service discovery:
- Updates in near real-time as pods change
- Integrates with health checks to avoid routing to failing instances
- Supports advanced routing (version splits, canary deployments) without application changes
- Works seamlessly across namespaces and clusters
Key Takeaway: Service mesh service discovery automatically maintains dynamic routing information by watching infrastructure changes and updating sidecar proxies, eliminating hardcoded endpoints and enabling intelligent traffic management without application code changes.