Chapter 5. Service Discovery
One challenge arising from adopting the cattle approach to managing infrastructure is service discovery. If you subscribe to the cattle approach, you treat all of your machines equally and you do not manually allocate certain machines for certain applications; instead, you leave it up to a piece of software (the scheduler) to manage the life cycle of the containers.
The question then is, how do you determine which host your container ended up being scheduled on so that you can connect to it? This is called service discovery, and we touched on it already in Chapter 4.
The Challenge
Service discovery has been around for a whileâessentially, as long as distributed systems and services have existed. In the context of containers, the challenge boils down to reliably maintaining a mapping between a running container and its location. By location, I mean its IP address and the port on which it is reachable. This mapping has to be done in a timely manner and accurately across relaunches of the container throughout the cluster. Two distinct operations must be supported by a container service discovery solution:
- Registration
-
Establishes the
container -> location
mapping. Because only the container scheduler knows where containers âlive,â we can consider it to be the absolute source of truth concerning a containerâs location. - Lookup
-
Enables other services or applications to look up the mapping we stored during registration. Interesting properties ...
Get Container Networking now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.