What is the ClusterIP service type?
The ClusterIP service type in Kubernetes exposes a service on an internal IP address within the cluster. It makes the service reachable only from within the cluster, meaning that applications inside the cluster can access the service using ClusterIP.
A high-level visualization of the traffic flow using ClusterIP is shown in Figure 7.1 (the complete source code can be found here in our GitHub repo:chapter-7/cluster-ip-svc.yaml). The source code representing this figure is the following:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-sample
namespace: default
spec:
...
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
...