Service Discovery vs Static Endpoints: When to Switch
When to replace static endpoints with service discovery: signals to switch, when static is fine, Kubernetes DNS, Consul, Eureka and migration steps.
Use service discovery instead of static endpoints when service instances change often: autoscaling, containers that get new IPs on restart, rolling deployments, multiple environments or regions. Keep static endpoints for a few stable dependencies, such as a managed database or a third-party API behind a fixed hostname, where a registry would add moving parts without solving a problem.
This guide is about the decision itself: what static endpoints are, what they cost as a system grows, which signals tell you it is time to switch, and how to migrate without an outage. For a comparison of discovery with service meshes, see service discovery versus service mesh, and for very large clusters see which discovery approaches scale best in Kubernetes.
Key takeaways
- A static endpoint is an address written into configuration: an IP, a hostname, or a load balancer URL that someone updates by hand.
- Service discovery keeps a live list of healthy instances and lets clients find them by name. Kubernetes Services and DNS, Consul and Eureka are common options.
- Switch when instances are short-lived, scale automatically, or move between hosts, or when manual endpoint updates cause incidents.
- Static endpoints are still fine for a few stable dependencies, especially managed services that already sit behind a fixed DNS name.
- In Kubernetes you already have discovery: a Service gets a DNS name such as
my-svc.my-namespace.svc.cluster.local. - Migrate gradually: put a stable name in front of existing endpoints first, then move the name onto a discovery system.
What static endpoints are
A static endpoint is any address a service uses to reach another service that does not change unless a person changes it. It might be an IP address in an environment variable, a hostname in a properties file, or the URL of a load balancer that someone created by hand and registered servers behind. Many systems start this way because it is simple and it works when there are three servers that never move.
Static endpoints are not always raw IPs. A fixed DNS name pointing at a cloud load balancer is also static from the client's point of view. The question is not whether DNS is involved, but whether the list of real backends behind the name is updated automatically as instances come and go, and whether unhealthy instances are removed without someone noticing first.
What service discovery does
Service discovery has two parts. A registry keeps track of which instances of each service exist and whether they are healthy. A lookup mechanism lets clients find those instances by a logical name instead of an address.
Instances get into the registry in one of two ways. With self-registration, each instance registers itself on startup and sends heartbeats. Netflix Eureka, used through Spring Cloud Netflix, works this way: clients register with the Eureka server and are removed if heartbeats stop. With third-party registration, a platform component watches workloads and registers them. Kubernetes does this: the control plane tracks Pods selected by each Service and publishes their addresses in EndpointSlices.
Lookup also comes in two styles. In client-side discovery, the client queries the registry and picks an instance itself, often with a library that load balances. In server-side discovery, the client calls a stable address such as a load balancer, proxy or virtual IP, and that component picks a healthy instance. A Kubernetes ClusterIP Service is server-side: the client calls one virtual IP and kube-proxy or the dataplane forwards to a Pod.
Kubernetes Services and DNS
Every Kubernetes Service gets a DNS name in the form my-svc.my-namespace.svc.cluster-domain.example, usually ending in cluster.local. For a normal Service, the name resolves to the Service's cluster IP. For a headless Service (with clusterIP: None), the name resolves to the IPs of all selected Pods, which suits clients that do their own balancing or stateful sets. Named ports also get SRV records. Inside a namespace, a short name such as orders works because of DNS search domains; across namespaces, use orders.payments or the full name.
apiVersion: v1
kind: Service
metadata:
name: orders
namespace: payments
spec:
selector:
app: orders
ports:
- name: http
port: 80
targetPort: 8080
Clients then call http://orders.payments.svc.cluster.local, and Kubernetes keeps the backend list current as Pods restart, scale or move. Only Pods that pass their readiness probes receive traffic.
Consul
HashiCorp Consul keeps a service catalog where instances register their address and port, runs health checks, and removes unhealthy instances from results. Clients can find services through Consul's DNS interface, where a basic lookup has the form <service>.service.consul, or through its HTTP API. Consul works across virtual machines, containers and Kubernetes, which makes it a common choice for hybrid estates where not everything runs in one cluster.
Cloud-native registries
Cloud providers offer their own options, such as AWS Cloud Map, which maps logical names to backend resources and returns only healthy instances through API calls or DNS, and load balancers with target groups that autoscaling groups update automatically. These give a static-looking name to clients while the backend list changes underneath, which is often enough for services that run on virtual machines.
The cost of static endpoints as systems grow
Static endpoints break down in predictable ways once a system grows past a handful of servers.
- Every change is manual. Adding an instance, replacing a failed host or moving to a new subnet means editing configuration in every client and redeploying. Someone forgets one.
- Unhealthy instances keep receiving traffic. Without health checks feeding the endpoint list, a dead server stays in rotation until a person removes it.
- Autoscaling cannot help. New instances launched by an autoscaler are useless if clients do not know they exist.
- Containers break the model. Pods and tasks get new IPs every time they restart, so a written-down address may be wrong within minutes.
- Environments drift. Different endpoint lists for dev, staging and production get copied and edited by hand, and a staging service ends up calling a production database.
- Failover is slow. Moving traffic to another zone or region means changing configuration under pressure during an incident.
Signals that it is time to switch
You do not need service discovery on day one. These signals show the static approach has started to cost more than it saves:
- Services run in containers or on autoscaled instances whose addresses change.
- Deployments are rolling or blue/green, so instance sets change several times a day.
- An incident was caused or prolonged by a stale endpoint or a dead instance left in a list.
- Engineers spend time updating and redeploying configuration only to change addresses.
- The number of services is growing and each one needs to call several others.
- You run in more than one zone, region or cloud and need traffic to follow healthy instances.
- You want to add retries, circuit breaking or mutual TLS between services, which usually build on discovery.
If two or three of these apply, discovery will likely reduce both toil and incident risk.
When static endpoints are still the right choice
Discovery is a system you have to run, secure and monitor. For some dependencies it adds no value.
- Managed databases, caches and queues that the cloud provider exposes through a stable DNS name already handle failover behind that name.
- Third-party APIs you call by a public hostname are outside your registry anyway.
- A small application with two or three long-lived services may never change enough to justify a registry.
- Bootstrapping: the address of the discovery system itself, or of a core identity service, often has to be static.
A good rule is to keep static configuration for things that change rarely and are managed by someone else, and use discovery for your own services that change often.
Comparing the approaches
| Aspect | Static endpoints | Service discovery |
|---|---|---|
| Setup effort | Very low | Moderate; built in on Kubernetes |
| Handling instance changes | Manual edits and redeploys | Automatic registration and removal |
| Health awareness | None unless a load balancer adds it | Health checks or readiness remove bad instances |
| Autoscaling support | Poor | Native |
| Failure modes | Stale addresses, dead hosts in rotation | Registry outage, DNS caching, misconfigured checks |
| Best fit | Few stable or managed dependencies | Containers, autoscaling, many services, multi-region |
Migrating from static endpoints
A big-bang switch is risky. A gradual path works better.
- Inventory dependencies. List which services call which, and where each address is configured.
- Introduce stable names first. Replace raw IPs with DNS names that point at the current backends. Clients now depend on a name, not an address, and nothing else changes yet.
- Add health checks. Define what healthy means for each service, such as an HTTP endpoint that checks dependencies lightly. Discovery is only as good as its health signal.
- Register services. On Kubernetes, create Services with correct selectors and readiness probes. Outside Kubernetes, register instances in Consul or a cloud registry, ideally from your provisioning or deployment tooling rather than by hand.
- Move the name. Point the stable DNS name at the discovery system, or switch clients to the discovery name, one service at a time, starting with low-risk internal callers.
- Remove the old lists. Delete hard-coded endpoints once traffic has moved, so nobody uses them by accident.
- Monitor the registry. Alert on registry health, DNS errors and services with zero healthy instances.
Pitfalls after switching
DNS caching can undo the benefit. Some runtimes and libraries cache DNS answers for a long time, so clients keep calling old addresses after instances change. Check the TTL behaviour of your language runtime and HTTP client. Connection pooling has a similar effect: long-lived connections stay pinned to old instances, so set maximum connection lifetimes.
Weak health checks put broken instances into rotation. A check that only confirms the process is running will pass while the service cannot reach its database. Strong checks that call every dependency can cause cascades when one shared dependency slows. Aim for checks that reflect whether the instance can serve requests.
The registry becomes critical infrastructure. Run it highly available, back it up where it stores state, and decide how clients behave if it is unreachable. Many clients keep using the last known good list, which is usually the right choice.
Cross-namespace and cross-cluster lookups need care in Kubernetes. Short names resolve within the caller's namespace, so data in one namespace does not reach data in another. Use explicit names and document them.
A worked example
Consider an order service that calls inventory and payment services. In the static version, the order service has INVENTORY_URL=http://10.0.4.21:8080 in its configuration. When the inventory team adds a second instance for load, nobody updates the order service, so all traffic still goes to the first. When that host fails at night, orders fail until someone edits the variable and redeploys.
After the move to Kubernetes, inventory runs as a Deployment with a Service named inventory in the stock namespace and a readiness probe on /healthz. The order service now calls http://inventory.stock.svc.cluster.local. The inventory team scales from two to ten replicas with a Horizontal Pod Autoscaler, and the order service does nothing. A Pod that fails its readiness probe stops receiving traffic. The payment provider, an external API, stays as a static hostname, because it is managed by someone else and already sits behind its own load balancing.
The result is fewer configuration changes, faster recovery from instance failures and a clear split between internal services that use discovery and external dependencies that use fixed names.
Where this fits in delivery pipelines
Discovery makes CI/CD simpler. A pipeline no longer needs to update other services' configuration when it deploys new instances; registration happens as part of the platform. Blue/green and canary releases can shift traffic between instance groups behind one name. Environment differences shrink because services find each other by the same logical names in every environment. For deeper practice, our Consul interview questions cover registry design questions, and our service mesh use cases show what you can add on top of discovery.
Kubernetes networking and Services are core topics in the CKA exam. Our CKA course covers them with labs, in the Kharadi, Pune classroom and live online across India.
FAQs
What is the difference between service discovery and static endpoints?
Static endpoints are addresses written into configuration and changed by hand. Service discovery keeps an automatically updated list of healthy instances that clients look up by name.
When should I use service discovery?
When instances change often because of containers, autoscaling, rolling deployments or multiple regions, or when stale endpoints have caused incidents.
Does Kubernetes have built-in service discovery?
Yes. Each Service gets a DNS name such as my-svc.my-namespace.svc.cluster.local, and Kubernetes keeps its backend Pods updated through EndpointSlices and readiness probes.
What is a headless Service?
A Kubernetes Service with clusterIP set to None. Its DNS name resolves to the IPs of the selected Pods instead of a single virtual IP, so clients can connect to Pods directly.
What is the difference between client-side and server-side discovery?
In client-side discovery the client queries the registry and chooses an instance. In server-side discovery the client calls a stable address, and a load balancer or proxy chooses the instance.
Is DNS enough for service discovery?
Often, if the DNS records are updated automatically from a registry with health checks, as in Kubernetes or Consul. Watch for clients that cache DNS answers too long.
Should I put my managed database behind service discovery?
Usually not. Managed databases already expose a stable DNS name that handles failover, so a static endpoint is fine for them.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0