What is the cluster IP in Kubernetes?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction to Cluster IP in Kubernetes
Cluster IP is an integral part of Kubernetes services, specifically designed to facilitate internal communication within a Kubernetes cluster. Kubernetes, an open-source container orchestration platform, uses different types of services to manage the network traffic and expose applications. Among these services, the Cluster IP is the default service type, providing a stable virtual IP address to which inside-cluster components can connect.
Understanding Cluster IP
When a Kubernetes service of type Cluster IP is created, Kubernetes assigns an IP address from its internal IP range. This IP is known as the "Cluster IP" and is only reachable from within the cluster.
Key Characteristics:
- Internal Networking: Cluster IP is only accessible within the cluster's internal network.
- Stable IP Address: Once created, the Cluster IP remains constant unless the service is deleted and recreated.
- Load Balancing: The Cluster IP service automatically load balances traffic across the pods that are part of the service's endpoints.
Technical Explanation
When a user defines a service in Kubernetes, the platform creates an entry in internal DNS, mapping the service name to the cluster IP address. This allows other pods within the cluster to reach this service using a consistent name.
The internal process of accessing a Cluster IP service typically involves:
- Service Definition: Define a service in a manifest file, specifying the service type as
ClusterIP. - DNS Resolution: Kubernetes' internal DNS resolves the service name to the assigned Cluster IP.
- IP Tables and Load Balancing: The cluster's network uses IP tables (or similar technologies) to route requests to one of the associated pods, distributing load evenly.
Example of Cluster IP Service Definition
Here's an example of a Kubernetes service definition using Cluster IP:
- protocol: TCP
- Microservices architecture where services need to communicate internally.
- Backend services not meant to be accessed directly by external users.
- Internal databases or caching services.
- Efficiency: Reduces the necessity for network traffic to exit and re-enter the cluster, enhancing performance.
- Security: Limits exposure to internal components, protecting them from external threats.
- Simplicity: Establishes a straightforward way to create stable internal connections using consistent service names.
Related reading
- What is the correct way to install addons with Kubernetes 1.1?
- What is the current equivalent of kubectl run --generatorrun/v1
- What is the default memory allocated for a pod
- What is the difference between a Kubernetes Controller and a Kubernetes Operator?
- What is the difference between a Docker image and a container?
- What is the difference between a Docker image and a container?
- What is the difference between a port and a socket?
- What is the difference between a resourceVersion and a generation?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.