ClusterIP Service

This service is required when we need communication among the pods running inside nodes in a cluster.

Pods get assign IP addresses which usually change during their life cycle. It is necessary to use some textual address or their name instead of IP. This is achieved using ClusterIP service.

Resource file for clusterIP service is shown below.

apiVersion: v1
kind: Service
metadata:
  name: nginx-clusterip-service
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 80
  selector:
    type: router

With this, pod can be reached with service name nginx-clusterip-service.