A Kubernetes Service gives a changing set of Pods 1 stable IP address and 1 DNS name. 5 things to know before you put traffic on one:
Bottom line
- Service = a stable address for Pods that come and go. Pods get new IPs every time they are replaced. The Service IP and name stay
- A Service finds Pods by label. The selector matches Pod labels, and the control plane keeps the list of matching Pod IPs, with their readiness, in EndpointSlices
- There are 4 types, and 3 of them stack. ClusterIP is internal. NodePort adds a port on every node. LoadBalancer adds a cloud load balancer in front. ExternalName is a DNS alias
- ONLY ready Pods get traffic. A Pod that fails its readiness probe stops receiving traffic from every Service that selects it
- A Service balances connections at layer 4. It picks a Pod at random for each new connection. It knows nothing about HTTP paths, hosts or TLS certificates
A small Service that works, on Kubernetes v1.37:
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- name: http
port: 80
targetPort: 8080The 4 commands you will use most:
kubectl apply -f service.yaml
kubectl get svc web
kubectl describe svc web
kubectl get endpointslices -l kubernetes.io/service-name=webServices that time out, or a load balancer bill that keeps growing? Get a free DevOps assessment: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.
Find your situation:
- You are writing your first manifest: a Service YAML you can copy
- You are choosing a type: the 4 Service types
- A Service does not answer right now: debug a Service in 8 checks
- You wonder why you pay for 12 load balancers: what a LoadBalancer Service costs
- gRPC traffic lands on 1 Pod: how traffic gets to a Pod
- You want the main fields with their defaults: 12 spec fields
A Service is a stable address in front of changing Pods
Every Pod gets its own IP address. A Deployment creates and destroys Pods all day, so the set of IPs behind your app keeps changing.
Clients need 1 address that does not change.
Service = 1 virtual IP + 1 DNS name + a list of the Pods behind it.
What happens when you create one:
- You apply a Service with a selector, for example
app: web - The Service gets a cluster IP from the Service IP range, and a DNS name
- A controller scans for Pods whose labels match the selector, continuously
- It writes their IPs, ports and readiness into EndpointSlices
- kube-proxy on every node watches Services and EndpointSlices, and sets up the rules that redirect traffic for the Service IP to one of the Pods
A Pod dies โ it leaves the EndpointSlices. A new Pod with the same labels starts โ it joins. Nobody edits a config file.

The Service IP is virtual. The docs' words: it "never hits the wire". No single host answers for it. Each node rewrites the destination of the packet to a real Pod IP.
Why not plain DNS with several records? The Kubernetes docs give the reasons: DNS clients ignore TTLs (how long an answer may be cached), some apps look a name up once and cache the result forever, and low TTLs put a heavy load on DNS.
Service vs Deployment
A Deployment runs your app: it manages ReplicaSets and Pods. A Service exposes it: it gives those Pods an address.
They are linked by labels only. The Service does not know the Deployment exists.
That is why the same Service keeps working through a rollout: old Pods and new Pods carry the same label. (The rollout side is covered in the Kubernetes Deployment guide.)
A Service YAML you can copy: port, targetPort and nodePort
The Deployment side and the Service side, with the 3 lines that must agree:
# In the Deployment's Pod template
metadata:
labels:
app: web # 1. the label
spec:
containers:
- name: web
image: registry.example.com/web:1.4.2
ports:
- name: http-web # 2. the port name
containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web # 1. must match the Pod label
ports:
- name: http
protocol: TCP
port: 80 # 3. the port clients call
targetPort: http-web # 2. the container port, by nameThe 3 port fields, in 1 line each:
- port: the port of the Service. Clients call
web:80 - targetPort: the port on the Pod. A number from 1 to 65535, or the name of a container port. It defaults to the value of
port - nodePort: the port opened on every node, for NodePort and LoadBalancer Services only. Kubernetes picks one from 30000 to 32767 unless you set it

I use a named targetPort. The next release of the app can move from 8080 to 9090, and the Service does not change.
2 rules for the ports list:
- A Service with more than 1 port needs a unique name on every port
- Port names are lowercase letters, digits and
-.123-abcis valid,123_abcis rejected. A container port name (the one a namedtargetPortpoints at) is also limited to 15 characters
The quick way, when a Deployment already exists:
kubectl expose deployment web --port=80 --target-port=8080 --name=webWhat you get back:
$ kubectl get svc web
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
web ClusterIP 10.0.1.175 <none> 80/TCP 5s
$ kubectl get endpointslices -l kubernetes.io/service-name=web
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
web-ytpni IPv4 8080 10.244.0.5,10.244.0.6,10.244.0.7 5s3 addresses = 3 Pods that match the selector. The column lists Pods that are not ready too, so it proves the selector works and nothing more.
An empty ENDPOINTS column (<unset> or <none>, by kubectl version) is the first thing to look for when a Service does not answer.
The 4 Service types and when to use each
The type field takes 4 values. ClusterIP is the default.
| Type | What you get | Reachable from | Use it for |
|---|---|---|---|
| ClusterIP | A virtual IP inside the cluster | Pods in the cluster | Almost every Service: APIs, databases, queues |
| NodePort | ClusterIP + the same port on every node | Anything that reaches a node IP | Your own load balancer in front, quick tests |
| LoadBalancer | NodePort + a load balancer from your cloud | The internet or your VPC | The entry point: an Ingress or Gateway controller, or a TCP service |
| ExternalName | A DNS alias (a CNAME record) to an outside name | Pods in the cluster | An alias for an external database or API |
The first 3 are nested. Each level adds to the previous one.

The one exception: a LoadBalancer Service with allocateLoadBalancerNodePorts: false, for load balancers that send traffic straight to Pod IPs.
ClusterIP: the default, and the one you want most of the time
The IP comes from the range set by the API server flag --service-cluster-ip-range. It is reachable from inside the cluster only.
The cluster IP stays the same for the life of the Service. Delete and recreate the Service and it usually gets a different one, which is one more reason to call Services by name.
NodePort: a port on every node
- The default range is 30000 to 32767. The API server flag
--service-node-port-rangechanges it - Every node listens on the port and forwards to a ready Pod, on any node
- Ask for a specific
nodePortand you get it, or the API call fails - Pick your own ports from 30000 to 30085. Automatic assignment uses 30086 to 32767 first, so a collision is unlikely (stable since v1.29)
One difference to know before you change proxy mode: in iptables mode a NodePort answers on all node IPs by default, and in nftables mode only on the node's primary IP.
LoadBalancer: your cloud does the work
Kubernetes does not ship a load balancer. The type asks your cloud provider for one.
The steps: the Service starts as a NodePort โ the cloud controller creates the load balancer and points it at the nodes โ the address shows up under EXTERNAL-IP.
It is asynchronous. Until the load balancer exists, kubectl get svc shows <pending>.
On a cluster with nothing that provides load balancers (bare metal, many local clusters) it stays pending forever. MetalLB is the one I see most on bare metal.
What each cloud creates:
| Cloud | What a LoadBalancer Service creates | Internal instead of public |
|---|---|---|
| AWS (EKS) | A Network Load Balancer with the AWS Load Balancer Controller or EKS Auto Mode. The legacy built-in controller creates Classic Load Balancers and gets critical fixes only | service.beta.kubernetes.io/aws-load-balancer-scheme: "internal" with the AWS Load Balancer Controller and Auto Mode. The legacy controller reads service.beta.kubernetes.io/aws-load-balancer-internal: "true" |
| Google Cloud (GKE) | A passthrough Network Load Balancer | networking.gke.io/load-balancer-type: "Internal" |
| Azure (AKS) | A new frontend IP and rules on the cluster's Standard Load Balancer | service.beta.kubernetes.io/azure-load-balancer-internal: "true" |
On AWS, check the scheme before you apply. With the AWS Load Balancer Controller a new Network Load Balancer is internal by default, and internet-facing is something you ask for.
Check which controller owns the Service too. The AWS Load Balancer Controller picks a Service up only through loadBalancerClass: service.k8s.aws/nlb or the annotation service.beta.kubernetes.io/aws-load-balancer-type: "external".
2 fields I set on a public LoadBalancer Service:
loadBalancerSourceRanges, when only known IP ranges should connect (if the cloud supports it)externalTrafficPolicy: Local, when the app needs the real client IP. More on that below
ExternalName: a DNS alias, with 2 traps
apiVersion: v1
kind: Service
metadata:
name: orders-db
spec:
type: ExternalName
externalName: my.database.example.comPods look up orders-db and get a CNAME to the outside name. No proxying, no selector, kube-proxy is not involved.
The 2 traps:
- HTTP and TLS: the client sends the Host header
orders-db, which the origin does not recognize, and the origin's certificate does not match the name the client used - IP addresses: an IPv4 string in
externalNameis treated as a DNS name made of digits and does not resolve. For an IP, use a Service without a selector
Headless: no virtual IP at all
Set clusterIP: None. The type stays ClusterIP.
No virtual IP, no kube-proxy, no load balancing. DNS returns the IPs of the ready Pods and the client picks one.
Use it when the client must know every Pod: StatefulSet members such as a database cluster, and gRPC clients that balance on their own.
A Service without a selector
Leave the selector out and Kubernetes creates no EndpointSlices. You write them yourself:
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: legacy-db-1
labels:
kubernetes.io/service-name: legacy-db
addressType: IPv4
ports:
- name: postgres
protocol: TCP
port: 5432
endpoints:
- addresses:
- "10.4.5.6"2 things must match the Service: the kubernetes.io/service-name label, and the port name (the Service needs a port named postgres too). The name of the EndpointSlice does not matter.
I use this during migrations: the app calls legacy-db from day 1, the database moves into the cluster later, and the app config never changes.
DNS: call a Service by its name
Every Service gets a DNS record:
web.shop.svc.cluster.local
| |
| namespace
Service nameWhat to type, by where the client runs:
| Client is in | Name to use |
|---|---|
| The same namespace | web |
| Another namespace | web.shop |
| Anywhere, spelled out | web.shop.svc.cluster.local |
The short name works because each Pod's /etc/resolv.conf carries 3 Kubernetes search domains, starting with its own namespace, and ndots:5. (cluster.local is the default cluster domain. Yours can differ.)
A bare web resolves only inside the Service's own namespace. A team that copies a config from one namespace to another finds this out fast.
A normal Service resolves to its cluster IP. A headless Service resolves to the IPs of all its ready Pods. Named ports also get SRV records (DNS records that carry a port).
Kubernetes also injects environment variables such as WEB_SERVICE_HOST and WEB_SERVICE_PORT into Pods. They exist only for Services created before the Pod started. Use DNS.
How traffic gets from the Service IP to a Pod
kube-proxy runs on every node. It watches Services and EndpointSlices and programs the node's kernel to redirect Service traffic.
It works at layer 4, the transport layer: TCP, UDP and SCTP.
The path of a connection, in the default iptables mode:
- A Pod opens a connection to the Service IP and port
- A rule on the node picks 1 backend Pod at random
- The destination is rewritten to that Pod's IP and
targetPort - Every packet of that connection goes to the same Pod
The 3 modes on Linux, as of v1.37:
| Mode | Status | What to do |
|---|---|---|
| iptables | The default in v1.37. A future version changes the default to nftables | Set the mode explicitly, so an upgrade does not switch it for you |
| nftables | Stable since v1.33. Needs kernel 5.13 or newer | The direction to plan for. Rule updates are faster on large clusters |
| ipvs | Deprecated since v1.35. Planned: off by default in v1.40, gone by v1.43 at the latest | Migrate to nftables |
To see what a kubeadm cluster runs:
kubectl -n kube-system get configmap kube-proxy \
-o jsonpath='{.data.config\.conf}' | grep 'mode:'An empty mode: "" means the default, iptables.
kube-proxy is the default, and it can be replaced. Cilium, for example, can take over its job completely. The Service API stays the same for you.
gRPC and HTTP/2 stick to 1 Pod
The backend is picked when the connection opens.
An HTTP/1.1 connection carries 1 request at a time, so clients open several connections and replace them often, and requests spread out. A gRPC client opens 1 long-lived HTTP/2 connection and sends every request over it.
The result: 1 client, 5 Pods, and 1 of them does all of that client's work. (The other 4 are very relaxed.)
The 2 fixes the Kubernetes blog describes:
- A headless Service, and a client that balances across the Pod IPs it gets from DNS
- A proxy or service mesh that balances per request
Session affinity and traffic distribution
sessionAffinity: ClientIPsends a client IP to the same Pod. The timeout defaults to 10800 seconds (3 hours). Affinity by cookie or header does not exist at this layertrafficDistribution: PreferSameZonekeeps traffic in the client's zone when a Pod is available there, and falls back to the whole cluster. Stable since v1.35. It can cut cross-zone data transfer costtrafficDistribution: PreferSameNodeprefers a Pod on the same node, then the zone, then the clusterinternalTrafficPolicy: Localis strict: with no Pod on the client's node, the traffic is dropped
Only ready Pods receive traffic
Readiness is the switch between a Pod and its Services.
- A Pod passes its readiness probe โ its IP is a ready endpoint
- A Pod fails its readiness probe โ its endpoint is marked not ready, and every Service that matches it stops sending it traffic
- A Pod with no readiness probe counts as ready when its containers run, even while the app is still booting

Each endpoint in an EndpointSlice has 3 conditions:
| Condition | Meaning |
|---|---|
| serving | The Pod is passing its readiness check |
| terminating | The Pod is being deleted |
| ready | serving and not terminating |
During shutdown, 2 things run in parallel: the kubelet starts stopping the containers, and the control plane marks the endpoint as not ready.
In parallel means a Pod can receive a few more connections after it got SIGTERM. The usual fix is a short preStop sleep and a graceful shutdown.
One safety net: when all endpoints of a Service are terminating, proxies send traffic to the ones that are still serving. That keeps a rolling update from dropping everything.
A Service with no endpoints at all: kube-proxy, in its iptables and nftables modes, rejects the connection.
The client IP is lost on NodePort and LoadBalancer by default
| Traffic | Source IP the Pod sees |
|---|---|
| Pod to ClusterIP | The client Pod's IP |
| NodePort, default | A node IP |
| LoadBalancer, default | A node IP |
NodePort or LoadBalancer with externalTrafficPolicy: Local | The real client IP |
Why: with the default policy (Cluster), any node accepts the traffic and may forward it to a Pod on another node. To get the reply back, the node replaces the source address with its own.
externalTrafficPolicy: Local = a node sends traffic to its own Pods only.
The trade-offs of Local:
- Nodes without a Pod of the Service fail the load balancer's health check and get no traffic
- The spread across Pods can be uneven: 1 Pod on node A gets as much as 3 Pods on node B
- No second hop between nodes
A load balancer that terminates the connection itself (a proxy) hides the client IP either way. There you read X-Forwarded-For, or turn on the PROXY protocol (a header the load balancer adds with the client address).
A LoadBalancer Service costs money per Service on AWS
On AWS, every LoadBalancer Service gets its own load balancer. AWS says it plainly: a Network Load Balancer cannot be shared across Services.
(AKS works differently: Services share 1 Standard Load Balancer, and each one gets its own frontend IP.)
The math, with the $0.0225 per hour from AWS's us-east-1 pricing examples:
- 1 load balancer: $0.0225 x 730 hours = about $16.43 a month, before capacity units and data
- 12 Services of type LoadBalancer: about $197 a month, before any traffic
The bill is the small problem. 12 public entry points = 12 places for TLS, firewall rules and DNS records.
My rule: 1 load balancer per cluster for HTTP, and ClusterIP for everything behind it.
How: 1 LoadBalancer Service in front of an Ingress or Gateway controller, which routes by host and path to ClusterIP Services.
Service vs Ingress vs Gateway API
| Service | Ingress | Gateway API | |
|---|---|---|---|
| Layer | 4: TCP, UDP, SCTP | 7: HTTP and HTTPS | 4 and 7 |
| Routes by | IP and port | Host and path | Host, path, headers, and TCP or UDP routes |
| Backends are | Pods | Services | Services |
| Status | Stable | Frozen: stable, kept, no new features | The successor. v1.7.0 is the latest release (October 29, 2026) |
Ingress is a way in for HTTP. It is a separate object from a Service, and it needs Services behind it.
Non-HTTP traffic from outside (a database port, a message broker) goes through a NodePort or LoadBalancer Service, or through the Gateway API's TCP and UDP routes.
The ingress-nginx project was retired in March 2026, and the Kubernetes project recommends Gateway over Ingress. For a new cluster I start with the Gateway API. The details are in the Kubernetes Ingress guide.
12 spec fields and their defaults
| Field | Default | What it does |
|---|---|---|
type | ClusterIP | ClusterIP, NodePort, LoadBalancer or ExternalName |
selector | none | The Pod labels to match. Equality only. Empty = you manage the endpoints |
ports[].port | required | The port of the Service |
ports[].targetPort | the value of port | The port on the Pod, by number or name |
ports[].protocol | TCP | TCP, UDP or SCTP |
ports[].nodePort | assigned from 30000 to 32767 | The port on every node |
clusterIP | assigned | An IP from the Service range, or None for headless. Cannot be changed later, except by a type change to or from ExternalName |
sessionAffinity | None | None or ClientIP (timeout 10800 seconds) |
externalTrafficPolicy | Cluster | Cluster or Local, for traffic from outside |
internalTrafficPolicy | Cluster | Cluster or Local, for traffic from inside |
trafficDistribution | unset: spread evenly | PreferSameZone or PreferSameNode |
ipFamilyPolicy | SingleStack | SingleStack, PreferDualStack or RequireDualStack |
2 fields to stop using:
externalIPs: deprecated since v1.36 (the reason is CVE-2020-8554). The EXTERNAL-IP column ofkubectl get svcis a different thing and staysloadBalancerIP: deprecated since v1.24. Use your provider's annotation
Debug a Service in 8 checks
The checks come from the Kubernetes "Debug Services" page, reordered so the common causes come early. Checks 4, 5 and 7 run from a Pod inside the cluster:
kubectl run -it --rm --restart=Never busybox \
--image=registry.k8s.io/busybox:1.27.2 sh| # | Check | Command | A failure means |
|---|---|---|---|
| 1 | The Service exists | kubectl get svc web | NotFound: nobody created it, or wrong name or namespace |
| 2 | It has endpoints | kubectl get endpointslices -l kubernetes.io/service-name=web | Empty: the selector matches no Pod in this namespace |
| 3 | The Pods are ready | kubectl get pods -l app=web | READY shows 0/1: the Pod matches and fails its readiness probe, so it gets no traffic |
| 4 | DNS resolves | nslookup web, then nslookup web.shop | The client is in another namespace, or cluster DNS is down |
| 5 | The Service IP answers | wget -qO- 10.0.1.175:80 | DNS is fine and the path behind it is broken: go on |
| 6 | The ports are right | kubectl get service web -o json | Wrong targetPort, a named port the Pods do not have, wrong protocol |
| 7 | The Pods answer directly | wget -qO- 10.244.0.5:8080 | The app is the problem. Use the Pod port here: 8080 |
| 8 | Nothing blocks the path | kubectl get networkpolicy, then kube-proxy logs on the node | A NetworkPolicy that does not list the client, or kube-proxy is not running |
In a hurry, start with checks 2 and 3. A selector that matches nothing and Pods that are not ready are the 2 causes I see most often.
The 2 usual causes of an empty list:
- A label typo. The Service selects
app=weband the Deployment labels its Podsrun=web - The wrong namespace. A Service selects Pods in its own namespace only
Addresses are listed and the Service still does not answer โ the Pods are not ready, or the port is wrong.
2 notes on the commands:
kubectl get endpointsstill works and prints a deprecation warning since v1.33. The Endpoints API also cuts off at 1000 addresses. Use EndpointSliceskubectl port-forward service/web 8080:80forwards to 1 Pod picked from the Service. It proves the Pod works. It does not test the Service's balancing
More commands, grouped by task, are in the kubectl cheat sheet.
What changed for Services in Kubernetes v1.33 to v1.37
- v1.33: nftables mode for kube-proxy became stable. The Endpoints API was deprecated in favor of EndpointSlices.
trafficDistributionbecame stable - v1.35: ipvs mode was deprecated.
PreferSameZoneandPreferSameNodebecame stable, andPreferCloseis now a deprecated alias ofPreferSameZone - v1.36:
externalIPswas deprecated - v1.37: a Service name may start with a digit. kube-proxy warns when no proxy mode is set explicitly
If your notes about Services are from 2022, the commands still run, and 3 things they recommend are deprecated: the Endpoints API, ipvs mode and externalIPs.
Checklist before a Service takes production traffic
Always:
- ClusterIP unless something outside the cluster must connect
- The selector uses a label that only this app's Pods carry
targetPortpoints at a named container port- Every port has a name
- The Pods have a readiness probe that reflects the app
- Clients call the DNS name, and the namespace is part of it across namespaces
- 1 shared entry point for HTTP, through an Ingress or Gateway controller
- Internal load balancers carry the internal annotation of your cloud and of your controller
externalTrafficPolicy: Localwhere the app needs the client IP- gRPC goes through a headless Service or a proxy that balances per request
- The kube-proxy mode is set explicitly, and no cluster still runs ipvs
- No
externalIPs, noloadBalancerIP, nokubectl get endpointsin scripts
Kubernetes Service FAQ
What is a Kubernetes Service?
A Service is the Kubernetes object that exposes an app running in 1 or more Pods under 1 stable IP address and DNS name. It finds its Pods by label and sends each new connection to one of the ready ones.
What are the 4 types of Services in Kubernetes?
ClusterIP, NodePort, LoadBalancer and ExternalName. ClusterIP is the default and is reachable inside the cluster only, NodePort opens a port on every node, LoadBalancer adds a cloud load balancer, and ExternalName is a DNS alias. A headless Service is a ClusterIP Service with clusterIP: None.
What is the difference between a Service and a Deployment?
A Deployment runs and replaces Pods. A Service gives those Pods a stable address. They are separate objects linked only by labels, and most apps need both.
What is the difference between ClusterIP, NodePort and LoadBalancer?
Each one includes the previous. ClusterIP is an internal virtual IP, NodePort adds a port from 30000 to 32767 on every node, and LoadBalancer adds an external load balancer from your cloud provider that forwards to those nodes.
What is the difference between port, targetPort and nodePort?
port is the port clients call on the Service. targetPort is the port the container listens on, and it defaults to port. nodePort is the port opened on every node for NodePort and LoadBalancer Services.
Do I need an Ingress if I have a LoadBalancer Service?
For 1 HTTP app, no. For several, yes: an Ingress or Gateway controller behind 1 load balancer routes by host and path, and you stop paying for a load balancer per app.
Why does my Service have no endpoints?
The selector does not match the labels of any Pod in the Service's namespace. Compare kubectl describe svc NAME with kubectl get pods --show-labels. If the addresses are listed and traffic still fails, check whether the Pods pass their readiness probe.
Does a Kubernetes Service load balance?
Yes, per connection: each new connection goes to a ready Pod picked at random. Requests inside 1 long-lived connection, as with gRPC, all go to the same Pod.
A recap
If you take away 1 thing, let it be this:
A Service is a label selector with a stable address. When it breaks, check the selector, the readiness probe and the port.
You don't need a DevOps expert for that. The YAML above and the 8 checks cover most cases.
If you would like a second pair of eyes on your cluster networking anyway (yes, I sell DevOps engineers), the free DevOps assessment is where a senior engineer reviews your Kubernetes and cloud setup.
Related guides: Kubernetes Deployment, Kubernetes Ingress and Kubernetes vs Docker.




