liveBook · Manning

Clusterip service type

As explained in Kubernetes for Developers

ClusterIP is a Kubernetes Service type that assigns a cluster-internal IP address for access from within the cluster.

A ClusterIP Service gives an application a virtual IP address reachable from Pods inside the Kubernetes cluster. Use it when one internal component needs to call another without exposing that component publicly. section 7.1

Kubernetes tracks the Pods selected by the Service and routes requests to one of them. This provides internal load balancing while hiding changing Pod IP addresses from calling applications. section 7.1.1

Choose ClusterIP when:

  • A frontend needs to call an internal backend, avatar generator, or database deployment. section 7.1.2
  • Access should remain inside the cluster; the Service has no external IP. section 7.1.2
  • External access is required through another design, such as NodePort or LoadBalancer, rather than direct ClusterIP access. section 7.1

Expose an internal Robohash service

Define a Service with type ClusterIP, select the Robohash Pods, and map port 80 to the container’s port 80. Other Pods can then request the assigned cluster IP, such as http://10.63.254.218/example. To test it locally, run kubectl port-forward service/robohash-internal 8080:80 and visit http://localhost:8080/example. section 7.1.2

Figure 7.1 IP routing for an internal service named Robohash. The Frontend-1 Pod makes an internal request to the service. The iptables’ routing glue on the node has a list of Pods for the Service, which is supplied by the Kubernetes control plane, and selects the Pod named Robohash-2 at random. The request is then routed to that Pod via its node.
07-01

Trace how a request from a frontend Pod reaches one selected backend Pod through node networking and the Kubernetes control plane’s Service endpoint list. section 7.1.1

How Kubernetes for Developers covers it

How deep it goes
Explains virtual IP routing and Pod load balancing, but stops short of detailed networking implementation.
Examples
Uses a Robohash Deployment, Service manifest, cluster IP request, and kubectl port-forward test.
What it assumes
Assumes familiarity with Pods, Deployments, Services, and basic kubectl operations.
What you can do after
Operate/configure an internal Kubernetes Service and test it from a local machine with kubectl port-forward.
How it connects
Relates Services to Pods, NodePort, LoadBalancer, Ingress, and microservice architecture.

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 for Developers. The section links point to the parts of the book it draws on.