Skip to content
Opsfolk
Kubernetes

Kubernetes Services, DNS and Ingress Explained

How Kubernetes Services, kube-proxy, CoreDNS and Ingress get traffic to Pods: ClusterIP, NodePort, EndpointSlices, ndots:5, Gateway API and debugging.

admin27 min readUpdated

Services, DNS and Ingress: how traffic finds a Pod. A request passes an ingress gate to the Service, which sends it on to one of three Pods on two nodes; CoreDNS sits below.
On this page

In the last part, the kubelet started a Pod on worker-2, its readiness probe passed, and the Pod became Ready. It has an IP address, say 10.244.2.17, and it can take traffic. But nothing should send traffic to that address. The next rollout replaces the Pod, and its replacement gets another address on another node. Scale the Deployment to five, and there are five addresses, changing every time a Pod restarts somewhere else.

Kubernetes answers that problem with three layers, and this part of Kubernetes Internals: How a Cluster Really Works follows a request through all of them. A Service gives a set of Pods one stable virtual IP, and kube-proxy turns that IP into a real Pod on every node. Cluster DNS gives the Service a name, so clients never need the IP either. And Ingress, or its successor the Gateway API, brings HTTP traffic from outside the cluster to the right Service. At the end, we turn it around: given a Service that does not answer, how to find which layer is broken.

New to the series? Start with Kubernetes API Server Explained: The Life of a Request, then How the Kubernetes Scheduler Works and Kubelet and Container Runtimes.

What Is a Kubernetes Service?

Definition: A Kubernetes Service is an API object that gives a set of Pods, chosen by a label selector, one stable virtual IP address, a DNS name and a port. Traffic sent to the Service is load-balanced to the Pods that are Ready, and the set follows the Pods as they come and go.

Three facts frame the rest of this article:

  • A Service is not a process. Nothing listens on a Service's IP. It is a record in the API server, and every node turns it into kernel rules that rewrite packets addressed to it. No packet ever reaches "the Service": it reaches a Pod, chosen by the first node the packet passes through.
  • Its Pods are chosen by labels, not by name. A Service with selector: {app: web} selects every Pod in its namespace labelled app: web, whichever Deployment made it. A Pod that loses the label leaves the Service; a Pod that has it by mistake joins it.
  • It only sends traffic to Pods that are Ready. The readiness probe from the last part is what decides it. A Pod that is running but not Ready stays out of the Service until its probe passes.

Here is the Service the rest of this article uses, in front of a Deployment of three web Pods in the namespace shop:

yaml
apiVersion: v1
kind: Service
metadata:
  name: web
  namespace: shop
spec:
  selector:
    app: web
  ports:
  - name: http
    port: 80          # the port clients connect to, on the Service's IP
    targetPort: 8080  # the port the container listens on
    protocol: TCP

kubectl expose deployment web --port 80 --target-port 8080 writes the same object. A targetPort can also be the name of a container port (targetPort: http), which lets different Pods of the same Service listen on different numbers.

How a Service Works, at a Glance

How a request reaches a Pod through a Service, step by step:

  1. Create: you create the Service. The API server gives it a ClusterIP from the cluster's service range (10.96.0.0/12 on kubeadm clusters), say 10.96.0.20, and stores it.
  2. Select: the EndpointSlice controller, in the kube-controller-manager, watches Services and Pods. It finds the Pods that match the selector and writes their IPs, ports and readiness into EndpointSlice objects owned by the Service.
  3. Program: kube-proxy, a DaemonSet with one Pod per node, watches Services and EndpointSlices, and writes kernel rules on its node: packets to 10.96.0.20:80 go to one of 10.244.1.5:8080, 10.244.2.17:8080, 10.244.3.9:8080.
  4. Name: CoreDNS watches the same objects, and answers web.shop.svc.cluster.local with 10.96.0.20.
  5. Resolve: a client Pod connects to http://web.shop. Its resolver asks CoreDNS and gets the ClusterIP.
  6. Rewrite: the client's first packet leaves its network namespace for 10.96.0.20:80. On the client's node, kube-proxy's rules pick one backend and rewrite the destination (DNAT) to that Pod's IP and port.
  7. Route: the packet is routed to the chosen Pod, on this node or another, by the Pod network that the CNI plugin set up.
  8. Return: the kernel's connection tracking remembers the rewrite. Every later packet of the connection goes to the same Pod, and each reply has its source rewritten back to 10.96.0.20:80, so the client never sees the Pod's address.

CoreDNS, kube-proxy and the EndpointSlice controller watch the API server; a client resolves web.shop, connects to the Service's IP, and its node's rules rewrite it to one of three Pods.

Notice who is involved. The API server stores the objects, the EndpointSlice controller, CoreDNS and kube-proxy watch them, and the kernel of the client's node does the work on every packet. When something breaks, it is one of those, and the debugging section at the end goes through them in that order.

Service Types: ClusterIP, NodePort, LoadBalancer and More

Every Service has a type, and each type adds one way in on top of the one before it:

Type What it gives you Reachable from Typical use
ClusterIP (the default) A virtual IP inside the cluster Pods and nodes of the cluster Service-to-service traffic
NodePort A ClusterIP, plus a port opened on every node, from 30000-32767 Anything that can reach a node's IP Quick tests, or behind a load balancer you run yourself
LoadBalancer A NodePort, plus an external load balancer provisioned for it The internet, or a private network Exposing one Service outside the cluster
ExternalName A DNS CNAME to another name, with no proxying Pods of the cluster Giving an outside database an in-cluster name
Headless (clusterIP: None) No virtual IP: DNS returns the Pods' IPs Pods of the cluster StatefulSets, clients that pick their own backend

A few details that matter in practice:

  • A NodePort is opened on every node, whether or not a Pod of the Service runs there. A packet that arrives at <any node>:30080 is rewritten to one of the Service's Pods, possibly on another node. You can pick the port (nodePort: 30080) or let the API server choose one.
  • A LoadBalancer is made by someone else. Kubernetes only records the request. On a cloud, the cloud controller manager sees the Service, creates a load balancer that sends to the nodes' NodePort, and writes its address into status.loadBalancer.ingress. On bare metal, nothing does this until you install a project such as MetalLB, and the Service's EXTERNAL-IP stays <pending> forever.
  • An ExternalName Service is only a DNS record. kind: Service, type: ExternalName, externalName: db.example.com makes orders-db.shop.svc.cluster.local a CNAME to db.example.com. There is no ClusterIP and no kube-proxy rule, and a TLS certificate or HTTP Host check on the other side sees the name the client used.
  • A headless Service has a selector and EndpointSlices, but no virtual IP. kube-proxy ignores it. DNS answers its name with the IP of each Ready Pod, and, for a StatefulSet, gives each Pod a name of its own: postgres-0.postgres.shop.svc.cluster.local.

Where ClusterIPs Come From

The service range is set by the API server's --service-cluster-ip-range flag, and since Kubernetes 1.33 it is also an object you can read and extend: a ServiceCIDR named kubernetes is created from the flag, and every ClusterIP given out is recorded as an IPAddress object.

bash
kubectl get servicecidrs
kubectl get ipaddresses | head

A ClusterIP is never reused while its Service exists, and it is never a real interface on any machine. That is why ping 10.96.0.20 usually fails: kube-proxy's rules match a Service's protocol and ports, and ICMP to the IP matches none of them.

Selectors, EndpointSlices and Readiness

The Service object says which Pods it wants. The EndpointSlices say which Pods it has right now. You can read them like any other object:

bash
kubectl get endpointslices -n shop -l kubernetes.io/service-name=web
NAME        ADDRESSTYPE   PORTS   ENDPOINTS                           AGE
web-7xq2k   IPv4          8080    10.244.1.5,10.244.2.17,10.244.3.9   3d

Each endpoint in a slice carries the Pod's IP, the node it runs on, its zone, and three conditions:

Condition Meaning Who uses it
ready The Pod is Ready and not terminating kube-proxy sends new connections only to these, when there are any
serving The Pod passes its readiness probe, whether or not it is terminating kube-proxy falls back to these when no endpoint is ready, so a rollout that ends with every Pod terminating keeps serving
terminating The Pod has a deletionTimestamp Load balancers that drain connections

A slice holds at most 100 endpoints by default, so a Service with 250 Pods has three slices, and a change to one Pod rewrites one small slice instead of one large list. That is why EndpointSlices replaced the older Endpoints object, which kept every address of a Service in one object. The Endpoints API is deprecated since Kubernetes 1.33: it still works, but reading it returns a warning, and new tools should read EndpointSlices.

The chain from the last part closes here. When a Pod's readiness probe fails three times, the kubelet sets its Ready condition to False, the EndpointSlice controller marks the endpoint not ready, kube-proxy on every node removes it from its rules, and new connections stop reaching it, all within a second or two of the status change.

Services Without a Selector

A Service can have no selector at all. Then no controller writes its EndpointSlices, and you write them yourself, with the label kubernetes.io/service-name: <service>. This is how you give an outside address, a database on a VM say, a ClusterIP and a cluster DNS name, with the load balancing of a normal Service. Set addressType, the IPs and the ports, and keep the slice up to date yourself.

kube-proxy: Turning a Virtual IP into a Pod

kube-proxy is misnamed. In its usual modes it does not proxy anything: no packet passes through the kube-proxy process. It is a controller that watches Services and EndpointSlices, and writes rules into the kernel of its node. The kernel then rewrites packets on its own, at full speed, even if kube-proxy is stopped. What stops working without kube-proxy is the updating: a new Service or a moved Pod is not reflected on that node until it comes back.

It has three modes on Linux:

Mode How it matches a Service Status in Kubernetes 1.37
iptables Chains of iptables rules in the nat table, walked in order The default
nftables One nftables table with verdict maps, a single lookup per packet Stable since 1.33, needs kernel 5.13 or later, the recommended mode for new clusters
ipvs The kernel's IPVS load balancer, with iptables around it Deprecated since 1.35, to be switched off by default in 1.40

A future release will make nftables the default, so set the mode explicitly in kube-proxy's configuration (mode: nftables) rather than relying on the default.

A connection's first packet to 10.96.0.20:80 matches KUBE-SERVICES, a random rule picks an endpoint, DNAT rewrites it to the Pod's IP, and conntrack sends later packets the same way.

Inside the iptables Rules

The iptables mode is still the most common, and its rules are easy to read once you know their shape. Every packet that leaves a Pod, or arrives at the node, goes through the KUBE-SERVICES chain. It has one rule per Service port, and the rule for web jumps to a chain of its own:

-A KUBE-SERVICES -d 10.96.0.20/32 -p tcp --dport 80 -j KUBE-SVC-WEB
-A KUBE-SVC-WEB -m statistic --mode random --probability 0.33333 -j KUBE-SEP-POD1
-A KUBE-SVC-WEB -m statistic --mode random --probability 0.50000 -j KUBE-SEP-POD2
-A KUBE-SVC-WEB -j KUBE-SEP-POD3
-A KUBE-SEP-POD1 -p tcp -j DNAT --to-destination 10.244.1.5:8080

The real chain names end in a hash, and the rules carry a comment with the Service's name (shop/web:http), which is what you grep for. The interesting part is the probabilities. With three endpoints, the first rule takes a connection with probability 1/3. Of the two thirds left, the second takes half, which is also 1/3 of the whole. The last takes whatever is left. Each Pod gets a third of the new connections, chosen at random, and the rules are rewritten with new probabilities every time an endpoint comes or goes.

Two consequences follow:

  • The choice is per connection, not per request. The rules run on a connection's first packet only. Connection tracking (conntrack) remembers the choice, and every later packet follows it. A client that keeps one HTTP/2 or gRPC connection open sends all its requests to one Pod, however many there are. For those protocols, balance requests in the client or in a service mesh, not in kube-proxy.
  • The walk is linear. A packet tests the KUBE-SERVICES rules one by one. With ten thousand Services, that is a lot of rules for every new connection, and rewriting them takes seconds. The nftables mode replaces the walk with a map lookup, which is why it scales better.

Session Affinity

sessionAffinity: ClientIP makes kube-proxy send every connection from the same client IP to the same Pod, for three hours by default (sessionAffinityConfig.clientIP.timeoutSeconds: 10800). It is a blunt tool: clients behind the same NAT, or traffic a node has rewritten to its own address, share one IP, so they share one backend too. Use it for an application that keeps state in memory per client and cannot do better, not as a load-balancing setting.

The canvas below plays fifteen seconds of three clients opening connections to the web Service. Change the number of replicas, turn on session affinity, or take one Pod out of the Service halfway, and watch where the connections go.

Three clients open a connection to the Service web every half second for 15 seconds, and kube-proxy's iptables rules send each to one ready Pod at random. With three replicas the 30 connections split 10, 12 and 8. With session affinity on, each client keeps its first Pod: web-1 gets 20 and web-2 none. With web-1 not ready from 8 seconds, it gets 5, all before then, and the rest go to web-2 and web-3. With one replica and that switch on, the last 14 connections are refused. The controls set the replicas, session affinity and the Pod that leaves.

How a Service spreads connections

With the defaults, the 30 connections split 10, 12 and 8. The choice is random, so even thirty connections do not split evenly, and a few long-lived connections can load one Pod far more than the others. Turn on session affinity, and each client keeps the Pod its first connection drew: two of the three drew web-1, which takes 20 connections while web-2 takes none. Take web-1 out at 8 seconds, and it gets nothing after that moment: kube-proxy rewrote the chain for two Pods, with p = 0.50 for the first. With one replica and that switch on, no endpoint is left, and kube-proxy's rule for the Service rejects every new connection.

Replacing kube-proxy with eBPF

Some CNI plugins do kube-proxy's job themselves. Cilium with its kube-proxy replacement, and Calico in its eBPF data plane, load eBPF programs that pick the backend when the client's socket connects, before a packet is even built, and do the same on the node's interface for traffic from outside. There are no iptables chains to walk and no address to rewrite on each packet. The Service and EndpointSlice objects are the same; only the program that reads them changes. On such a cluster there is no kube-proxy DaemonSet, and iptables-save shows nothing about your Services. How those programs work, and what else they do for the Pod network, is in Kubernetes Networking Deep Dive.

Traffic Policies: Which Pods Are Eligible

By default, a connection to a Service can land on any Ready Pod of it, on any node. Three fields narrow that down.

externalTrafficPolicy applies to traffic that arrives from outside through a NodePort or a LoadBalancer:

Value Which Pods Client source IP Trade-off
Cluster (the default) Any Ready Pod, on any node Lost: the node rewrites it to its own IP (SNAT), so the reply comes back the same way Even spread, but an extra hop and no client IP
Local Only Pods on the node the packet arrived at Kept The client IP is preserved, but a node with no local Pod drops the traffic, so the load balancer must skip it

With Local, Kubernetes gives the Service a healthCheckNodePort, and cloud load balancers check it to send traffic only to nodes that have a Pod of the Service. Spread can be uneven: a node with one Pod and a node with five get the same share from the load balancer.

internalTrafficPolicy: Local does the same for traffic from inside the cluster: a client only reaches the Pods on its own node, or none. It is meant for node agents, such as a log collector run as a DaemonSet, that every Pod should reach on its own node.

trafficDistribution is a preference, not a rule. PreferSameZone sends a client to endpoints in its own zone when there are some, and PreferSameNode to endpoints on its own node, falling back to the others when there are none. Both are stable since Kubernetes 1.35, and on a cloud where traffic between zones is billed, PreferSameZone is often the cheapest single line you can add to a Service. The older value PreferClose is a deprecated alias for PreferSameZone.

Cluster DNS with CoreDNS

Clients do not use ClusterIPs. They use names, and CoreDNS answers them. It runs as a Deployment in kube-system, usually two replicas, behind a Service that is still called kube-dns for compatibility, at a fixed ClusterIP (10.96.0.10 on kubeadm clusters). The kubelet writes that address into every Pod's /etc/resolv.conf.

CoreDNS is configured by a Corefile, in the coredns ConfigMap. The default one, trimmed:

.:53 {
    errors
    health
    ready
    kubernetes cluster.local in-addr.arpa ip6.arpa {
       pods insecure
       fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    forward . /etc/resolv.conf
    cache 30
    loop
    reload
}

The kubernetes plugin watches Services and EndpointSlices and answers names under cluster.local from memory. forward sends every other name to the node's resolvers, and cache 30 keeps answers for up to 30 seconds.

The Records It Serves

Name Record Answer
web.shop.svc.cluster.local A / AAAA The Service's ClusterIP
postgres.shop.svc.cluster.local (headless) A / AAAA The IP of every Ready Pod of the Service
postgres-0.postgres.shop.svc.cluster.local A / AAAA One Pod of a StatefulSet, through its headless Service
_http._tcp.web.shop.svc.cluster.local SRV The port named http, and the Service's name
orders-db.shop.svc.cluster.local (ExternalName) CNAME The name in externalName
10-244-2-17.shop.pod.cluster.local A A Pod's IP, written with dashes

Search Domains and ndots:5

Here is the /etc/resolv.conf of a Pod in the namespace shop:

search shop.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.96.0.10
options ndots:5

The search list is why a client can write http://web or http://web.payments: the resolver appends each domain in turn until a name resolves. ndots:5 says when it does so: a name with fewer than five dots is first tried with each search domain, and only then as it is. A name with five or more dots, or one that ends in a dot, is tried as it is first.

That rule is generous inside the cluster and costly outside it. api.github.com has two dots, so a Pod that calls it first asks for api.github.com.shop.svc.cluster.local, then api.github.com.svc.cluster.local, then api.github.com.cluster.local, gets three NXDOMAIN answers, and only then asks for the real name. Most resolvers ask for the IPv4 and IPv6 address of each name, so that is eight queries for one lookup. Even web.shop.svc.cluster.local, written out in full, has four dots and goes through the search list first.

The canvas below runs the resolver's rule. Pick a name, change ndots, and count the queries a Pod in shop sends.

The DNS queries a Pod in the namespace shop sends for one name, with the search list shop.svc.cluster.local, svc.cluster.local and cluster.local. At the default ndots:5, web takes one query, while api.github.com takes four: three NXDOMAIN answers from CoreDNS before the real name is forwarded upstream, eight with the IPv6 queries. Even db.data.svc.cluster.local, written in full, takes four. A trailing dot, or ndots of 2 or less, sends api.github.com once. The controls pick the name and the ndots value.

How a Pod resolves a name

With the defaults, web costs one query and api.github.com four: three NXDOMAIN answers from CoreDNS, then the real name, forwarded upstream. db.data.svc.cluster.local, written in full, also costs four at ndots:5, because it has only four dots. Set ndots to 2, or write api.github.com. with its trailing dot, and the outside name is sent once. A lower ndots has its own cost: at ndots:1, db.data is first sent upstream as it is, and only finds the Service on its third query.

dnsPolicy, dnsConfig and NodeLocal DNSCache

A Pod's dnsPolicy decides what the kubelet writes into its resolv.conf:

dnsPolicy Resolver
ClusterFirst (the default) CoreDNS, with the search list above. Names outside the cluster domain are forwarded upstream by CoreDNS
ClusterFirstWithHostNet The same, for a Pod with hostNetwork: true, which would otherwise get the node's resolver
Default The node's own resolv.conf, with no cluster names. Despite its name, it is not the default
None Nothing: everything comes from the Pod's dnsConfig

dnsConfig adds to whatever the policy wrote, which is the clean way to lower ndots for one workload:

yaml
spec:
  dnsConfig:
    options:
    - name: ndots
      value: "2"

On a busy cluster, DNS is often the first thing to fall over. Every lookup is a UDP packet through conntrack to a CoreDNS Pod, usually on another node, and a conntrack race on simultaneous A and AAAA queries is a known cause of five-second lookup delays. NodeLocal DNSCache runs a small caching resolver as a DaemonSet on every node, on a link-local address such as 169.254.20.10. Pods ask their own node, cache hits never leave it, and misses go to CoreDNS over TCP.

Ingress: HTTP Routing from Outside the Cluster

A LoadBalancer Service per application works, but it costs a load balancer each, and it routes on IP and port only. Most traffic from outside is HTTP, and HTTP has a host name and a path to route on. That is what Ingress is for.

An Ingress has two parts, and confusing them is the most common Ingress problem:

  • The Ingress object is a set of rules: requests for this host and this path go to this Service and port. It does nothing on its own.
  • An Ingress controller is a reverse proxy running in the cluster (Traefik, HAProxy, NGINX Inc.'s NGINX Ingress Controller, a cloud provider's controller and many others) that watches Ingress objects and configures itself from them. It is usually exposed by one LoadBalancer Service, and all the cluster's HTTP traffic goes through it.

A cluster has no Ingress controller by default. An Ingress created without one is accepted, and nothing ever answers for it.

yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: shop
  namespace: shop
spec:
  ingressClassName: traefik      # which controller should serve it
  tls:
  - hosts: [shop.example.com]
    secretName: shop-example-com-tls
  rules:
  - host: shop.example.com
    http:
      paths:
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: api
            port:
              number: 80
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web
            port:
              name: http
  • ingressClassName names an IngressClass, which names the controller. Several controllers can run side by side, each serving its own class, and one class can be marked as the default for Ingresses that name none.
  • pathType is Exact, Prefix (matched by path element, so /api matches /api/orders but not /apis), or ImplementationSpecific, which means whatever the controller decides.
  • tls names a Secret of type kubernetes.io/tls in the same namespace. The controller ends TLS with it and talks plain HTTP to the Pods, unless it is told otherwise.

A browser's request goes to a cloud load balancer, a node's NodePort, then an Ingress controller, which reads Ingress rules and EndpointSlices and proxies straight to the api or web Pods.

Most controllers do not send traffic to the Service's ClusterIP. They read its EndpointSlices and proxy straight to the Pods' IPs, which avoids a second round of load balancing and lets them keep connections open to each Pod. The Service is still what they look up, which is why a Service with no endpoints answers 503 at the controller.

The ingress-nginx Retirement

For years, the most widely used controller was ingress-nginx, the community project maintained under the Kubernetes organisation. It was retired in March 2026: there are no more releases, bug fixes or security patches. Existing installations keep running, which is exactly the risk: a reverse proxy facing the internet that will not be patched again.

To see whether a cluster still runs it:

bash
kubectl get pods --all-namespaces --selector app.kubernetes.io/name=ingress-nginx

It is not the same project as NGINX Inc.'s NGINX Ingress Controller, which is maintained separately. The project's own advice is to move to the Gateway API, or to another maintained Ingress controller. Its annotations (nginx.ingress.kubernetes.io/...) were specific to it, so a migration is a rewrite of those, not a change of class name.

Gateway API: The Successor to Ingress

The Ingress API is stable and is not going away, but it is frozen: it gets no new features. Everything it cannot express, such as header matching, traffic splitting, rewrites or TCP routing, ended up in each controller's annotations, different for every controller. The Gateway API is the replacement designed by SIG Network, installed as a set of CRDs and implemented by most controllers and service meshes. Its current release is v1.6.

It splits Ingress's one object into three, one per role:

Object Owned by Says
GatewayClass The infrastructure provider Which controller implements Gateways of this class
Gateway The cluster operator Where traffic comes in: listeners, with their ports, protocols, host names and TLS certificates, and which namespaces may attach routes
HTTPRoute (and GRPCRoute, TLSRoute, TCPRoute, UDPRoute) The application team Which requests go to which Services, with what weights and filters
yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: web
  namespace: shop
spec:
  parentRefs:
  - name: public            # a Gateway, often in another namespace
    namespace: infra
  hostnames: ["shop.example.com"]
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - name: web
      port: 80
      weight: 90
    - name: web-canary
      port: 80
      weight: 10

The weights are a canary release with no annotation: nine requests in ten go to web, one to web-canary. A team can change its own route without touching the Gateway, and the operator decides which namespaces may attach to it.

Ingress Gateway API
Status Stable, frozen Stable core, still growing
Protocols HTTP and HTTPS HTTP, HTTPS, gRPC, TLS, TCP and UDP
Roles One object for everyone Class, Gateway and routes, owned apart
Header matching, rewrites, traffic splits Controller annotations In the API
Routes across namespaces No Yes, where the Gateway allows it
Portability between controllers Low, once annotations are used High, for the core features

For a new cluster, start with the Gateway API. For an existing one, the ingress2gateway tool converts Ingress objects into Gateways and HTTPRoutes, as a first draft to review.

Why a Service Does Not Reach Its Pods

When a request to a Service fails, the symptom usually names the layer:

Symptom Likely cause Where to look
Could not resolve host, NXDOMAIN A wrong name or namespace, or CoreDNS is down nslookup from a Pod in the client's namespace; CoreDNS's Pods and logs
Connection refused at once No Ready endpoint, or a wrong targetPort kubectl get endpointslices; the container's real port
Timeout A NetworkPolicy drops it, the Pod network is broken, or the app does not listen on the Pod's IP NetworkPolicies in both namespaces; a direct request to a Pod's IP
Some requests fail, others work One bad Pod still Ready, or rules stale on one node Request each Pod's IP; kube-proxy's logs on the failing node
503 from the Ingress controller The Service has no Ready endpoints The backend Service's EndpointSlices
404 from the Ingress controller No rule matches the host or path, or the Ingress names another class The Ingress's host, pathType and ingressClassName
EXTERNAL-IP <pending> Nothing provisions load balancers The cloud controller manager, or a bare-metal load balancer
A Service with no endpoints at all The selector matches no Pod: a typo, or the Pods are in another namespace kubectl get pods -l <selector> -n <namespace>

If the name fails, check DNS; with no Ready endpoints, the selector or probes; if a Pod's IP fails, the app or network; if only the Service fails, its targetPort or the node's rules.

Debugging a Service, Step by Step

1. Does the Service select any Pods?

bash
kubectl get service web -n shop -o wide
kubectl get endpointslices -n shop -l kubernetes.io/service-name=web
kubectl get pods -n shop -l app=web -o wide

An EndpointSlice with no endpoints means the selector matches nothing. Endpoints that are listed but not ready mean the Pods fail their readiness probe: that is the kubelet's story from the last part.

2. Does the name resolve, from where the client runs?

bash
kubectl run dns-test -n shop --rm -it --restart=Never \
  --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- nslookup web

Run it in the client's namespace: a short name resolves only there. If it fails, check CoreDNS: kubectl -n kube-system get pods -l k8s-app=kube-dns, then its logs.

3. Does a Pod answer on its own IP, and does the Service?

bash
kubectl run http-test -n shop --rm -it --restart=Never --image=busybox:1.37 -- \
  sh -c 'wget -qO- -T 3 http://10.244.2.17:8080/ ; wget -qO- -T 3 http://web/'

The Pod's IP and the container port first, then the Service. If the Pod answers and the Service does not, the problem is between them: the targetPort, or the node's rules. If neither answers, it is the app, the Pod network, or a NetworkPolicy.

Avoid kubectl port-forward svc/web for this test. It picks one Pod and tunnels to it through the API server and the kubelet, without going through kube-proxy's rules at all, so it proves the Pod works and nothing about the Service.

4. Did kube-proxy write the rules? On the client's node:

bash
sudo iptables-save | grep 'shop/web'                  # iptables mode
sudo nft list table ip kube-proxy | grep 'shop/web'   # nftables mode
kubectl -n kube-system logs -l k8s-app=kube-proxy --tail=50

No rules for a Service that has endpoints means kube-proxy on that node is not running, or cannot reach the API server.

5. Is something dropping the traffic?

bash
kubectl get networkpolicies -n shop

A NetworkPolicy that selects the web Pods allows only the traffic it lists: a client from another namespace, or a missing rule for DNS on port 53, looks exactly like a network failure.

Key Takeaways

  • A Service gives Pods chosen by labels one stable virtual IP and DNS name. Nothing listens on that IP: every node rewrites packets addressed to it.
  • The EndpointSlice controller lists a Service's Pods and their readiness; kube-proxy turns them into kernel rules; CoreDNS turns the Service's name into its ClusterIP.
  • kube-proxy picks a backend per connection, at random, and conntrack keeps it. A long-lived HTTP/2 or gRPC connection stays on one Pod.
  • iptables is still kube-proxy's default in 1.37; nftables is stable and recommended; IPVS is deprecated. eBPF data planes such as Cilium can replace kube-proxy entirely.
  • externalTrafficPolicy: Local keeps the client's IP but only uses Pods on the receiving node. trafficDistribution: PreferSameZone keeps traffic in its zone when it can.
  • With ndots:5, an outside name such as api.github.com costs three failed lookups before the real one. A trailing dot, or a lower ndots, avoids them.
  • An Ingress object does nothing without an Ingress controller. ingress-nginx is retired; the Gateway API is the successor, with roles split across GatewayClass, Gateway and routes.
  • To debug a Service, go layer by layer: endpoints, DNS, the Pod's own IP, kube-proxy's rules, NetworkPolicies.

FAQ

What is the difference between ClusterIP, NodePort and LoadBalancer?

A ClusterIP Service gets a virtual IP that only works inside the cluster. A NodePort Service adds a port, from 30000 to 32767, opened on every node, so anything that can reach a node can reach the Service. A LoadBalancer Service adds an external load balancer, made by the cloud provider or a tool such as MetalLB, that sends traffic to those node ports. Each type includes the one before it.

What does kube-proxy do?

kube-proxy runs on every node and watches Services and EndpointSlices in the API server. It writes kernel rules, with iptables, nftables or IPVS, that rewrite packets sent to a Service's IP and port so they reach one of its Ready Pods. In those modes no traffic passes through the kube-proxy process itself: the kernel does the forwarding.

What is the difference between a Service and an Ingress?

A Service gives a set of Pods a stable address and balances connections between them, at the IP and port level. An Ingress is a set of HTTP rules, by host name and path, that an Ingress controller uses to route requests from outside the cluster to Services. A typical setup has one LoadBalancer Service in front of the Ingress controller, and ClusterIP Services behind it.

Should I use Ingress or the Gateway API?

For new work, the Gateway API. It is the successor to Ingress, supports more protocols and features without controller-specific annotations, and splits configuration between the platform team and application teams. Ingress remains stable and supported, so existing Ingresses can stay, but move off ingress-nginx, which was retired in March 2026 and no longer gets security fixes.

What does ndots:5 mean in Kubernetes?

It is a resolver option in every Pod's /etc/resolv.conf. A name with fewer than five dots is first tried with each of the Pod's search domains, such as shop.svc.cluster.local, before being tried as written. It lets short names like web resolve to Services, but makes each lookup of an outside name such as api.github.com send several failed queries first. A trailing dot or a lower ndots in dnsConfig avoids them.

What is a headless Service?

A Service with clusterIP: None. It gets no virtual IP and kube-proxy ignores it; instead, DNS answers its name with the IP of each Ready Pod. StatefulSets use one to give each Pod a stable DNS name, such as postgres-0.postgres.shop.svc.cluster.local, and clients that choose their own backend, such as database drivers, use one to see every Pod.

Why does my Kubernetes Service have no endpoints?

Almost always because its selector matches no Pod, or the Pods it matches are not Ready. Compare the Service's selector with the Pods' labels in the same namespace, with kubectl get pods -l <selector>, then check the Pods' readiness probes. A Service without a selector has endpoints only if you write its EndpointSlices yourself.

What's Next

You have followed a request from a name to a Pod: CoreDNS turned the name into a ClusterIP, kube-proxy's rules turned the ClusterIP into a Pod, and an Ingress controller or a Gateway brought it in from outside. But the Pod at the end of that path keeps nothing: restart it, and its files are gone. In the next part of Kubernetes Internals: How a Cluster Really Works, we give it storage that outlives it: how PersistentVolumes, claims, StorageClasses and CSI drivers turn a YAML file into a mounted disk.


Comments

No comments yet.