liveBook · Manning

Peer discovery

As explained in Kubernetes in Action, Second Edition

Peer discovery is the process by which members of a distributed application locate and communicate with one another.

Peer discovery lets members of a distributed application find and communicate with one another. Keeping discovery in DNS avoids requiring the application to call the Kubernetes API directly. section 16.1.5

A headless Service associated with a StatefulSet resolves to the IP addresses of its Pods. Each Pod also receives an individual A or AAAA record, while SRV records provide Pod addresses and ports. section 16.1.5

MongoDB replica-set discovery

A MongoDB client can list replica addresses explicitly, such as quiz-0, quiz-1, and quiz-2, or use the SRV connection URI mongodb+srv://quiz-pods.kiada.svc.cluster.local. The Service port must be named mongodb so MongoDB finds the expected SRV record. section 16.1.5

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains explicit addresses, per-Pod DNS records, and SRV records, but stops short of DNS implementation internals.
Examples
Uses MongoDB replica addresses, StatefulSet Pod DNS names, SRV lookup, and a MongoDB data-importer command.
What it assumes
Assumes StatefulSets, Services, Pods, and DNS names; teaches why applications should avoid direct Kubernetes API discovery.
What you can do after
Apply peer discovery through Kubernetes headless Services and DNS-based MongoDB connection strings.
How it connects
Connects StatefulSets with headless Services, DNS, SRV records, Kubernetes API access, and MongoDB replica sets.

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.