Sign In

Curriculum 16: Services & Networking

ClusterIP Services

15 min · 25 XP

ClusterIP Services

ClusterIP is the default Service type in Kubernetes. It exposes the Service on an internal IP address reachable only from within the cluster. This makes it ideal for communication between microservices that don't need external access.

Creating a ClusterIP Service

apiVersion: v1
kind: Service
metadata:
  name: backend-api
  namespace: production
spec:
  type: ClusterIP
  selector:
    app: backend
  ports:
    - port: 80
      targetPort: 8080
      protocol: TCP
kubectl apply -f backend-service.yaml
kubectl get svc backend-api

DNS Resolution

Every ClusterIP Service gets a DNS entry following this pattern:

<service-name>.<namespace>.svc.cluster.local

For example, a Service named backend-api in the production namespace is reachable at:

backend-api.production.svc.cluster.local

Within the same namespace, you can use just the Service name:

curl http://backend-api

From a different namespace, use the full DNS name:

curl http://backend-api.production.svc.cluster.local

Inspecting Endpoints

Check which pods are backing your Service:

kubectl get endpoints backend-api -n production
kubectl describe svc backend-api -n production

The Endpoints object lists all pod IPs that match the Service selector. If no endpoints appear, verify your selector labels match the pods.

When to Use ClusterIP

Use ClusterIP for internal-only services such as databases, caches, and backend APIs that other cluster workloads consume. It provides stable networking without exposing anything outside the cluster.