A ClusterIP Service provides an internal cluster IP address for reaching a selected group of pods. It is the default Service type when no type is specified and is intended for communication within the cluster. section 11.1.2 section 11.2
The quote Service
A Service named quote can accept TCP connections on port 80 and forward them to port 80 on a pod matching the app=quote label selector. Applying its YAML manifest creates the Service through the Kubernetes API; kubectl expose provides an alternative for creating one from an existing pod. section 11.1.2
Listing 11.1 YAML manifest for the quote Service object
apiVersion: v1 #1
kind: Service #1
metadata:
name: quote #2
spec:
type: ClusterIP #3
selector: #4
app: quote #4
ports: #5
- name: http #5
port: 80 #5
targetPort: 80 #5
protocol: TCP #5
Use the manifest to inspect the essential fields: Service kind, ClusterIP type, pod selector, named port, target port, and TCP protocol. section 11.1.2
A ClusterIP Service connects clients and pods through these settings:
- The selector chooses pods whose labels match the configured key-value pairs. section 11.1.2
- The port is the port accepted by the Service, while targetPort identifies the destination port on selected pods. section 11.1.2
- Kubernetes normally assigns the internal cluster IP; setting clusterIP to None creates a headless Service. section 11.1.2
- ClusterIP does not provide external access; use externalIPs, NodePort, LoadBalancer, or Ingress when clients are outside the cluster. section 11.2





