Kubernetes service discovery works through two cooperating mechanisms: a stable virtual IP address and DNS name assigned to each Service, backed by EndpointSlices that track which pods are actually healthy and ready to receive traffic, and by kube-proxy or an equivalent dataplane that forwards packets to those pods. In other words, Kubernetes separates the name clients use from the pods that come and go behind it, and continuously reconciles the two.
That one-sentence answer needs a qualification to be accurate. "Service discovery" in Kubernetes covers three distinct layers that are often conflated: naming (how a client turns a Service name into an address), membership (how Kubernetes knows which pods belong to a Service and are eligible), and routing (how a connection to the Service address reaches a specific pod). Each layer has its own components and failure modes, and understanding the distinction is what makes the system predictable when something breaks.
The Core Problem Kubernetes Solves
Pods are ephemeral by design. A Deployment replaces pods during rollouts, a node failure reschedules them elsewhere, and a HorizontalPodAutoscaler adds or removes replicas. Every new pod gets a new IP address from the cluster's pod CIDR. If application A called application B by pod IP, every restart, scale event, or rescheduling would break the connection and require reconfiguration.
A Kubernetes Service is an abstraction that gives a set of pods a single, stable identity: a cluster-internal virtual IP (the ClusterIP), a DNS name, and a port. Clients address the Service, not the pods. The Service's selector identifies which pods belong to it, and Kubernetes maintains the mapping automatically as pods are created and destroyed. This is the heart of service discovery in Kubernetes: the name is stable, and the membership behind it is dynamic.
The Objects That Make It Work
Services
A Service of type ClusterIP is the default. It declares a selector, a port, and a target port. The API server assigns it a virtual IP from the service CIDR, and that IP is recorded in the cluster's data store. The virtual IP does not belong to any network interface or host; it is a routing construct that the dataplane implements. ClusterIP Services are reachable only from inside the cluster.
Services also come in NodePort and LoadBalancer types, which expose the same selector-based membership to traffic from outside the cluster, and in ExternalName type, which is a pure DNS alias with no proxying at all. The discovery mechanics differ: NodePort and LoadBalancer still rely on the same internal membership tracking, while ExternalName is handled entirely by CoreDNS returning a CNAME.
A Service with no selector is a special case. Kubernetes does not manage its endpoints automatically; instead, an administrator or controller creates EndpointSlice (or legacy Endpoints) objects manually, often to point at external databases or services in another cluster. This is a common pattern for bridging external dependencies into the cluster's naming scheme.
EndpointSlices
For every selector-based Service, a controller in the control plane watches pods and maintains EndpointSlice objects. Each slice lists a set of addresses — pod IPs, or node IPs in some external-traffic configurations — along with the ports and a ready condition per endpoint. A pod appears as a ready endpoint only when its readiness probe passes and it is not terminating in a way that removes it from service.
EndpointSlices replaced the older monolithic Endpoints object because a single Endpoints object for a large Service could grow to megabytes and force every watcher to re-download the whole thing on any change. Slices cap the number of endpoints per object (typically 100), so updates touch only a fraction of the data. The legacy Endpoints API still exists for compatibility, but new tooling and controllers should use EndpointSlices.
Membership is therefore not a static list. When a pod becomes ready, the EndpointSlice controller adds it. When it fails a readiness probe, the endpoint is marked not ready and is removed from the set used for routing. When it terminates, it is removed entirely. This is why readiness probes matter so much for service discovery: they are the signal that controls membership.
CoreDNS
Kubernetes runs a cluster DNS server, almost always CoreDNS, exposed as a Service in the kube-system namespace. CoreDNS watches Services and EndpointSlices and answers DNS queries for the cluster domain (default cluster.local). Every pod's /etc/resolv.conf is configured to point at the CoreDNS Service IP, with a search path that lets short names resolve.
A Service named payments in namespace shop gets DNS records including:
payments.shop.svc.cluster.local — the fully qualified name payments.shop — resolvable via the search path from pods in the shop namespace payments — resolvable from within the same namespace via the search path
For a normal ClusterIP Service, the DNS answer is the Service's virtual IP, not a pod IP. For a headless Service (clusterIP: None), CoreDNS returns the individual pod IPs from the EndpointSlices as A or AAAA records, which lets clients do their own load balancing or connect to specific replicas — the pattern StatefulSets rely on for stable per-replica DNS names.
CoreDNS also serves reverse DNS (PTR records) for Service IPs and pod IPs, which matters for some clients and for debugging.
The Dataplane: kube-proxy and Its Alternatives
DNS resolves the Service name to the ClusterIP, but the ClusterIP is virtual. Something on each node must intercept traffic destined for that IP and forward it to a real pod. Historically that was kube-proxy, which runs on every node and programs the kernel — via iptables in the default mode, or IPVS for larger clusters — with rules that rewrite the destination address to one of the ready endpoints. The choice among endpoints is effectively random per connection in iptables mode, giving basic load distribution.
Modern clusters increasingly replace kube-proxy entirely. Cilium, for example, implements service translation in eBPF programs attached to the network interfaces, which can be faster and more observable than iptables chains. Calico has similar capabilities. The important point for discovery is that the mechanism is pluggable: the API objects — Services, EndpointSlices, DNS — remain the contract, and the dataplane is an implementation detail. A client calls the DNS name, which resolves to the virtual IP, and the node's dataplane delivers the packet to a ready pod.
The End-to-End Path
A single request from one pod to another follows a sequence worth tracing concretely. Suppose a frontend pod in namespace web calls . The application's resolver reads /etc/resolv.conf, sees the web.svc.cluster.local search domain, and queries CoreDNS for api.web.svc.cluster.local. CoreDNS looks up the Service object and returns its ClusterIP — say 10.96.0.42. The application opens a TCP connection to 10.96.0.42:8080. On the node hosting the frontend pod, the dataplane matches the packet's destination against the Service's rules, chooses a ready endpoint from the EndpointSlice — say 10.244.3.17:8080 — and rewrites the packet to that address. The pod network delivers it to the backend, and the response is translated back so the frontend sees traffic from 10.96.0.42. The backend pod can see the original client IP only if the Service is configured to preserve it, because the address rewriting otherwise masks it.
Two details in this path cause most of the confusion operators encounter. First, DNS caching: a client that caches the ClusterIP will keep working even if the Service is deleted and recreated with a different IP, until the cache expires — which is why long-lived gRPC connections can hold a stale address. Second, connection reuse: because the dataplane chooses an endpoint per connection (in the common iptables implementation), a client that keeps a persistent connection will keep sending to one pod regardless of new replicas. Neither is a bug in discovery; both are consequences of the design, and both are addressed at the application layer with re-resolution or client-side load balancing.
Common Misconceptions Worth Clearing Up
"The ClusterIP is a real address." It is a virtual address that exists only as a routing rule. You cannot ping it, and it is not bound to any interface. Tools that treat it as a host address will mislead you. This is also why ping on a Service name fails while curl succeeds.
"DNS gives you the pods." For ordinary Services, DNS gives you the virtual IP. Only headless Services return pod IPs. If you want to enumerate backends, query EndpointSlices or use a headless Service.
"Readiness is optional." It is not, for discovery purposes. Without a readiness probe, a pod is considered ready as soon as its containers start, so it enters the endpoint set before it can serve traffic. The result is predictable-looking intermittent errors during rollouts.
"Service discovery is only for east-west traffic." It is, primarily, but the same objects and DNS names are what Ingress controllers, gateways, and external load balancers use to find backends. The Service is the internal contract even when the external exposure is via an Ingress or Gateway API resource.
"kube-proxy is required." The API objects are the contract; kube-proxy is one implementation. eBPF-based CNIs replace it without changing how applications discover Services.
What Service Discovery Does Not Do
Kubernetes service discovery is not a full service mesh. It does not provide retries, timeouts, circuit breaking, mutual TLS, or traffic splitting by itself — those come from the application, a service mesh, or the Gateway API's traffic-splitting features layered on top. It is also not a registry with rich metadata; you cannot attach arbitrary labels for discovery beyond the standard selector and endpoint machinery without custom controllers. And it does not solve cross-cluster discovery: a Service in one cluster is not automatically resolvable from another, which is why multi-cluster tooling, DNS federation, or service mesh federation exists.
It also does not guarantee that a chosen endpoint is alive at the moment of connection. Endpoint removal is reactive: the control plane notices a failed readiness probe or a deleted pod and removes it, but there is a window during which the dataplane still has the stale rule. Retries and connection draining at the application level cover that gap, and they are not optional in production.
Practical Implications
For most teams, the working rules are straightforward. Use readiness probes that reflect actual ability to serve. Prefer headless Services when you need per-pod addressing, such as for databases or StatefulSets. For gRPC and other long-lived connections, configure client-side load balancing or connection re-resolution rather than relying on the dataplane's per-connection choice. Name Services consistently with DNS-friendly names, and use the FQDN when crossing namespaces to avoid search-path surprises. When debugging, check in order: the Service selector matches the intended pods, the EndpointSlices show ready endpoints, CoreDNS resolves the name, and the dataplane rules are present on the node.
When something is wrong, the diagnostic order mirrors the layers: kubectl get endpointslices shows membership, kubectl get svc shows the virtual IP and ports, a test pod's nslookup confirms the DNS answer, and node-level inspection confirms the dataplane. Most "service discovery is broken" incidents resolve to one of three causes: a selector that does not match pod labels, a readiness probe that never passes, or a DNS or network policy issue blocking the CoreDNS query.
Kubernetes service discovery is ultimately a reconciliation loop rather than a lookup table. The Service declares intent, the controllers maintain the current membership, DNS publishes the stable name, and the dataplane realizes the forwarding. Once you see the four layers separately, the system stops looking magical and starts looking like what it is: a carefully separated naming and routing problem solved by continuous, automated agreement between the control plane and every node.