Skip to content
tezvyn:

ClusterIP Service: Internal-Only Networking

Source: kubernetes.ioEasyHow cards are made

ClusterIP Service: Internal-Only Networking

A ClusterIP service is like an unlisted phone number for your pods, providing a stable internal IP for communication *within* the cluster. Use it for backend-to-backend traffic. The footgun is assuming it's reachable from the outside—it's not.

Why it exists

Pods in Kubernetes are ephemeral; they can be created and destroyed at any time, getting a new IP address on each restart. Applications, like a frontend needing to talk to a backend, require a stable endpoint that doesn't change. ClusterIP solves this for internal traffic.

The mental model

Think of a ClusterIP service as an unlisted, internal phone number for a group of pods. It gives you a single, stable IP address that only works for calls made from inside the cluster. This IP address acts as a reliable entry point that automatically forwards requests to whichever backend pods are currently healthy and available.

How it works

When you create a ClusterIP service, Kubernetes assigns it a virtual IP address from a private range reserved for the cluster. The service uses a 'selector' to identify the set of pods it should send traffic to, based on their labels. A component on each node called kube-proxy watches for traffic destined for this virtual IP. It then intercepts the traffic and routes it to the actual IP of one of the healthy target pods, automatically providing simple load balancing.

When to use it

This is the default and most common service type. Use it for any communication between applications running inside the same Kubernetes cluster. Common scenarios include a web frontend calling a backend API, a service querying a database, or any microservice-to-microservice communication.

When not to use it

Do not use ClusterIP when you need to expose your application to traffic from outside the cluster. Its IP address is not reachable from the public internet by design. For external access, you must use a different service type like NodePort or LoadBalancer, or an Ingress object.

One canonical example

A 'webapp' Deployment needs to connect to a 'database' Deployment. You create a ClusterIP service named 'db-service' that targets the database pods. The webapp's configuration uses the DNS name 'db-service' to connect. Kubernetes DNS resolves this name to the service's stable ClusterIP, ensuring the connection works reliably even if the database pods are restarted or scaled.

Interview question

What is the primary problem a Kubernetes ClusterIP service is designed to solve?

  • a.Ensuring all communication between different microservices within the cluster is encrypted by default.
  • b.Managing the automatic scaling of pods based on CPU utilization or other metrics.
  • c.Providing a stable, internal network endpoint for pods that are frequently created and destroyed.Correct
  • d.Allowing external users to access applications running inside the cluster from the internet.
Why?

The card states that ClusterIP solves the problem of ephemeral pods needing a stable endpoint for internal traffic. Option C directly reflects this by highlighting the need for a consistent internal network address for pods with changing IPs. Option D is a common misconception; while services can expose applications, ClusterIP specifically does not provide external access.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles