A Society Analogy :
If you have lived in the gated society in the metro cities, you would have experienced that this society comprises multiple high-rise towers with multiple flats belonging to individual towers. Multiple families reside within each flat of the given tower. Imagine each tower having its own common address which in turn has a gateway to multiple flats with their own unique address, so if one has to reach out to a particular flat in tower B, it has to first locate the tower B gate address and then will be getting the access of local flat address lying within the tower B.
The address of tower A & Tower B can be considered similar to ClusterIP, this cluster IP’s of each tower acts like a single endpoint/ gateway (Service)to connect to each pod (Family) living in the given cluster having their own local IP addresses.
Let’s Understand ClusterIP Further With One More Example:
In any given cluster node there can be multiple types of Pods viz
Front-end pod
Backend pods
Redis pods
Database MySQL pods
etc…
Each of these types of pods lying within an internal cluster will have a different internal network IP, which is liable to change. In order, to talk to each other. For example, the front-end pod may be talking to the backend pods, backend pods, in turn, may require to talk to Redis pods, there is the requirement for a more reliable and efficient mechanism, ClusterIP is our friend here.
ClusterIP:
1. Expose virtual IP reachable from within the cluster
2. Mainly used to communicate between components of microservices
3. Also used to communicate between pods on different-2 nodes & default service type.
Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default that is used if you don't explicitly specify a type for a Service. You can expose the Service to the public internet using an Ingress or a Gateway.
This is the simplest type of service. It’s also the default type, which means if we create a service without a type attribute Kubernetes will assume we mean ClusterIP.
This type of service is used when we only need to give other applications that are running inside our cluster access to our pods. If we have, say, three replicas of application app-a and another application app-b needs a stable endpoint to access these replicas, we could create service-a using the ClusterIP type.