OpenFeign with Kubernetes: Do You Still Need Spring Cloud LoadBalancer?
Yes. This is one of the biggest changes from the old microservice architecture to Kubernetes. Short answer If your microservices are running inside Kubernetes: β Use OpenFeign forβ¦
Yes. This is one of the biggest changes from the old microservice architecture to Kubernetes.
Short answer
If your microservices are running inside Kubernetes:
- β Use OpenFeign for service-to-service communication.
- β Let Kubernetes Service handle load balancing.
- β You typically do not need Spring Cloud LoadBalancer.
Before Kubernetes (Traditional Spring Cloud)
Order Service
β
βΌ
OpenFeign
β
βΌ
Spring Cloud LoadBalancer (Earlier Ribbon)
β
βΌ
Eureka Server
β
βΌ
Instance 1
Instance 2
Instance 3
How it worked:
- Feign asked Eureka for all instances.
- Eureka returned a list of instances.
- Spring Cloud LoadBalancer chose one.
- Feign sent the request.
The client decided where to send the request (client-side load balancing).
With Kubernetes
Order Pod
β
βΌ
OpenFeign
β
βΌ
customer-service
(Kubernetes Service)
β
βΌ
kube-proxy / networking
β
ββββ΄βββββ¬ββββββ
βΌ βΌ βΌ
Pod 1 Pod 2 Pod 3
How it works:
- Feign sends the request to
http://customer-service. - Kubernetes DNS resolves
customer-serviceto the Service IP. - Kubernetes Service automatically forwards the request to one of the healthy pods.
Feign doesn’t know or care which pod receives the request.
So does Spring Cloud LoadBalancer disappear?
In most Kubernetes deployments:
Yes, practically.
You don’t configure:
- Eureka
- Ribbon
- Spring Cloud LoadBalancer
because Kubernetes already provides service discovery and load balancing.
Example
Your Feign client:
@FeignClient(name = "customer-service")
public interface CustomerClient {
@GetMapping("/customers/{id}")
Customer getCustomer(@PathVariable Long id);
}
Application configuration:
customer-service:
url: http://customer-service
Feign calls:
http://customer-service/customers/1
Kubernetes automatically routes it:
customer-service
β
βΌ
Pod A
Next request
βΌ
Pod C
Next request
βΌ
Pod B
No extra load-balancing code is required.
Why do some projects still include Spring Cloud LoadBalancer?
There are a few reasons:
- The same application runs both locally and in Kubernetes.
- The team hasn’t fully migrated from an older Spring Cloud architecture.
- They use advanced client-side load-balancing features or custom selection policies.
For a Kubernetes-only environment, it’s usually unnecessary.
Modern enterprise architecture
Kubernetes Cluster
------------------------------------------------
API Gateway
β
βΌ
Order Service
β
βΌ
OpenFeign
β
βΌ
customer-service (K8s Service)
β
βΌ
Pod 1
Pod 2
Pod 3
------------------------------------------------
Responsibilities
| Component | Responsibility |
|---|---|
| OpenFeign | Makes HTTP calls using a Java interface |
| Kubernetes DNS | Finds the destination service |
| Kubernetes Service | Load balances requests across healthy pods |
| Pods | Process the request |
So, in a modern Kubernetes-based microservice architecture, OpenFeign is still used, but Kubernetes is responsible for service discovery and load balancing, making Spring Cloud LoadBalancer generally unnecessary.