11 Exposing pods with services
This chapter covers
- Communication between pods
- Distributing client connections over a group of pods that provide the same service
- Discovering services in the cluster through DNS and environment variables
- Exposing services to clients outside the cluster
- Using readiness probes to add or remove individual pods from services
Instead of running a single pod to provide a particular service, people nowadays typically run several replicas of the pod so that the load can be distributed across multiple cluster nodes. However, that means all pod replicas providing the same service should be reachable at a single address so clients can use that single address, rather than having to keep track of and connect directly to individual pod instances. In Kubernetes, this is done by using Service objects.
The Kiada suite you’re building consists of three services: the Kiada service, the Quiz service, and the Quote service. So far, these have been three isolated services that you interact with individually, but the plan is to connect them, as shown in the figure 11.1.
Figure 11.1 The architecture and operation of the Kiada suite
The Kiada service will call the other two services and integrate the information they return into the response it will send to the client. Multiple pod replicas will provide each service, so you’ll need to use Service objects to expose them.