Skip to main content
In this lesson, we’ll deep-dive into the Kubernetes Service of type ClusterIP—the default Service type for in-cluster communication. In a typical multi-tier application (front-end, back-end, in-memory cache like Redis, and a database such as MySQL), each component lives in its own set of Pods. Since Pod IPs are ephemeral, you need a stable endpoint for reliable, load-balanced communication between tiers. A ClusterIP Service assigns a virtual IP and DNS name inside the cluster. Pods can address the Service by name (e.g., back-end), and Kubernetes will distribute traffic across the matching Pods.
The image is a diagram of a Kubernetes ClusterIP setup, showing a network of pods organized into front-end, back-end, and Redis layers, each with specific IP addresses.

Why Use a ClusterIP Service?

Defining a ClusterIP Service

Create service-definition.yml to expose your back-end Pods:
By default, spec.type is ClusterIP. If you omit it, Kubernetes will still create a ClusterIP Service unless you specify another type.

Key Fields

Pod Definition with Matching Labels

Ensure your Pods carry labels that match the Service’s selector:

Deploying and Verifying

Apply the Service and check its status:
Example output:
Now, any Pod in the cluster can reach the back-end tier by calling:
Kubernetes will automatically load-balance requests across all matching Pods.
Avoid mapping Service ports directly to host ports in production; use ClusterIP for secure, in-cluster traffic and consider Ingress or LoadBalancer types for external access.

Watch Video