Service Discovery Patterns
DNS-based, registry-based.
Overview
Service discovery lets clients find service instances dynamically. The four patterns below cover almost every infrastructure shape; the discipline is matching the pattern to the platform rather than picking by trend.
- DNS-based. Service names resolve to instance IPs via DNS. Familiar tooling, low learning curve.
- Registry-based. Consul, etcd, ZooKeeper as the registry. Rich metadata per service; clients query the registry.
- K8s native. Service objects plus kube-dns. Built into the platform; no extra components.
- Service mesh plus health-aware. Istio, Linkerd, Consul Connect handle discovery, mTLS, and retries; unhealthy instances removed automatically.
The approach
Three habits make service-discovery choice match the infrastructure: K8s-native for K8s workloads, Consul for VM workloads, service mesh when rich policy is needed.
- K8s Service for K8s workloads. kube-dns provides DNS-based discovery out of the box. Use it; do not invent.
- Consul for VM workloads. Service registry plus DNS interface. Mature tooling for non-Kubernetes deployments.
- Service mesh for rich policy. mTLS, traffic shaping, retries, circuit breakers. Worth the operational cost when these matter.
- Health checks integrated plus documented topology. Unhealthy instances removed automatically; per-environment discovery mechanism documented in the runbook.
Why this compounds
Each correctly-integrated service inherits the discovery pattern. Team distributed-systems expertise compounds; new services slot into the existing topology rather than reinventing it.
- Resilience. Health-aware discovery survives instance failures without operator action.
- Operational fit. Discovery matches the platform. Engineers debug what they know.
- Reusable patterns. Standard discovery integration captures conventions across services. New services copy from a working example.
- Year-one investment, year-two habit. The first service is heavy lift to wire correctly. By the third or fourth, the patterns are reflexive.