# Service Discovery

> Enable services to discover and communicate with each other

- **Category**: Cloud
- **Subcategory**: Behavioral
- **Canonical URL**: https://designpattern.fyi/patterns/k8s_service_discovery/

---

## Description
The Service Discovery pattern enables services to discover and communicate with each other within a Kubernetes cluster. Kubernetes provides built-in service discovery through DNS and environment variables. Services can discover each other using stable service names, and Kubernetes handles load balancing across pod instances.


## Use Cases
Use when services need to discover and communicate with each other or when you want built-in load balancing and service registry.





## Trade-offs


### Advantages

- Built-in service discovery

- Automatic load balancing

- Stable service names

- No additional infrastructure required




### Considerations & Drawbacks

- Limited to cluster-internal communication

- DNS resolution delays

- Requires service configuration







---
**Reference**: [Original Source](https://github.com/k8spatterns/examples/tree/master/behavioral/ServiceDiscovery)

