Service Discovery in Kubernetes
Kubernetes manages containerized microservice applications by creating pods. Pods are the building blocks of Kubernetes, where multiple containers are grouped together and share the same network interface. For every pod, Kubernetes assigns an IP that is reachable within the Kubernetes cluster; however, the pods are ephemeral in their nature. In other words, pods and their IPs could change when they are assigned to different nodes. In order to reliably access pods, Kubernetes provides an abstraction layer known as service
. Kubernetes services group a logical set of pods that can run on the different nodes inside the cluster and enable other pods to reach them over the service.
Let's imagine having a backend
deployment in Kubernetes with two replicas and a frontend
deployment with three replicas. To reach the backend
pods from the frontend
pods, the IPs of the backends
should be made available to the frontends
, as shown in Figure 5.9. Additionally...