Kubernetes Service: ClusterIP
Learn the default internal Service type, when to use it, and how DNS and endpoints make in-cluster communication reliable.
What Is ClusterIP?
ClusterIP is the default Service type in Kubernetes. It exposes a stable virtual IP that is reachable only inside the cluster.
When to Use It
ClusterIP is ideal for:
- frontend to backend communication
- API to database communication
- internal microservice traffic
Full YAML Example
apiVersion: v1
kind: Service
metadata:
name: backend
spec:
selector:
app: backend
ports:
- port: 80
targetPort: 8080
type: ClusterIP
DNS Name Format
Inside the cluster, the full DNS name looks like this:
backend.default.svc.cluster.local
The short name backend often works inside the same namespace.
Inspect the Service
kubectl get svc
kubectl get endpoints backend
If the endpoints list is empty, the Service selector probably does not match any ready pods.
Why ClusterIP Is the Default
Most services in Kubernetes talk to each other internally. ClusterIP supports that use case without exposing anything publicly.
Think of ClusterIP like an internal office extension number. People inside the building can call it, but outside callers cannot.
Reachability
Who can normally reach a ClusterIP Service?
Empty Endpoints
If `kubectl get endpoints backend` shows no addresses, what is a likely cause?