liveBook · Manning

Clusterip service type

As explained in Kubernetes in Action, Second Edition

A ClusterIP service is a Kubernetes Service that provides an internal cluster IP address for reaching a set of pods.

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

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains manifests, selectors, ports, addresses, and forwarding, but defers external exposure to other Service types.
Examples
Uses quote and quiz Services, YAML manifests, kubectl apply, kubectl expose, and service listings.
What it assumes
Assumes pods, labels, ports, and kubectl sufficiently to select application pods and apply a Service definition.
What you can do after
Operate/configure an internal Service with a manifest or kubectl expose, selecting pods and mapping Service ports to pod ports.
How it connects
Connects Kubernetes Service objects with pods, label selectors, ports, headless Services, NodePort, LoadBalancer, and Ingress.

Also explained in

Compare how 6 books explain clusterip service type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.