Pcornel
Browse topics
Options
Recent
Favorites
Containers · Technical reference

Service Types

Direct answer

Service types: ClusterIP (internal), NodePort (port on every node), LoadBalancer (cloud/MetalLB load balancer), ExternalName (DNS alias); headless Services return pod IPs.

When to use this

Use it to choose how a workload is exposed, or when a Service is unreachable.

First 30 seconds

1. kubectl get svc <s> -o wide — type, ports, external IP.

2. Endpoints present?

3. targetPort = container port?

4. LoadBalancer Pending → controller/MetalLB.

5. Test from inside and outside.

Operational verification

client → Service (ClusterIP/NodePort/LB) → endpoints

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Docker / containerd / Podman / Kubernetes / OCI-compatible platforms
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformDocker / containerd / Podman / Kubernetes / OCI-compatible platforms
Scope / prerequisiteUse it to choose how a workload is exposed, or when a Service is unreachable.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 How to verify Verify boundary

Confirm endpoints exist, then test the Service from a Pod, then from outside for NodePort or LoadBalancer. A pending EXTERNAL-IP means no load balancer controller is handling the Service.

Step 2 Common failures Narrow the fault

A selector that does not match Pod labels gives a Service with no endpoints. targetPort must match the container port, not the Service port. LoadBalancer stays pending on bare metal without MetalLB or similar.

Key points

Endpoints must exist; targetPort must match the container port. LoadBalancer Pending → no load balancer provider.

Key checks
  • kubectl get svc <s> -o wide — first check for this topic
  • kubectl get pods -o wide — pods, status, node, IP
  • kubectl describe pod <pod> — events and conditions
  • kubectl logs <pod> [-c <c>] [--previous] — container logs (incl. previous crash)
  • kubectl get events --sort-by=.lastTimestamp — recent cluster events
ReferenceWhat it is1 section · depth on demand

How it works

The control plane assigns a cluster IP and keeps EndpointSlices of ready Pods that match the selector. kube-proxy (iptables or IPVS) or an eBPF data plane programs nodes to forward the virtual IP to those endpoints.

ReferenceImportant terms & boundaries3 sections · depth on demand

Service types

TypeReachable fromUse
ClusterIPInside clusterDefault internal services
NodePortNode IP:30000–32767Simple external access, testing
LoadBalancerCloud/MetalLB external IPProduction external services
ExternalNameDNS CNAMEAlias to external names
Headless (clusterIP: None)DNS per PodStatefulSets

kubectl get endpointslices -l kubernetes.io/service-name=web — no endpoints means the selector does not match Ready Pods.

In depth

A Service gives a stable virtual IP and DNS name to a changing set of Pods. The control plane keeps EndpointSlices listing the Pod IPs that match the selector and are Ready; kube-proxy (iptables, IPVS or nftables mode) or an eBPF data plane translates the Service IP to one of them.

Ports in one Service

ports:
- port: 80          # what clients connect to on the Service IP
  targetPort: 8080  # container port (number or named port)
  nodePort: 30080   # only for NodePort/LoadBalancer

Traffic policies

SettingEffect
externalTrafficPolicy: Cluster (default)Any node forwards to any Pod; client IP is SNATed
externalTrafficPolicy: LocalOnly nodes with a local Pod accept traffic; client IP preserved
internalTrafficPolicy: LocalIn-cluster traffic stays on the node (node-local agents)
sessionAffinity: ClientIPSame client → same Pod (timeout 3 h by default)

Worked check — Service not answering

kubectl get svc web -o wide                     # selector and ports
kubectl get endpointslices -l kubernetes.io/service-name=web
# ENDPOINTS empty → selector mismatch or no Ready Pods
kubectl get pods -l app=web --show-labels
kubectl run t --rm -it --image=busybox:1.36 --restart=Never -- wget -qO- http://web:80

Empty endpoints with running Pods almost always means the selector labels differ, or readiness probes are failing. Endpoints present but no answer means targetPort points at the wrong container port.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • NodePort services exposed unintentionally.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
service typeskubernetes service typesnodeport loadbalancer
Confirmation

Confirm action

Continue?