How to configure load balancing when proxying to a downstream kubernetes service? #2251
-
Hi! This is a followup question to How do I proxy to a downstream kubernetes service. In the discussion it is mentioned that you can proxy to a downstream service by using the kubernetes service name as the Destination Address. "destination1": {
"Address": "http://my-service/"
} My question is how can you configure load balancing between multiple instances when proxying to a kubernetes service? In the original question there is mention of a kubernetes specific feature in Ocelot that uses the kubernets service name you configure to query the Kubernetes endpoints API. From this it obtains information on all downstream instances of the service and automatically load balances between them. Does Yarp have a similar feature implemented or planned? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you have DNS set up in a way that would return all instances, you could use the newly added reverseProxyBuilder.AddDnsDestinationResolver(); But there is nothing currently built-in to resolve all destinations from the k8s API ahead of time. |
Beta Was this translation helpful? Give feedback.
If you have DNS set up in a way that would return all instances, you could use the newly added
IDestinationResolver
(available in daily builds) to "explode" the list of destinations to all destinations returned by DNS for that host.But there is nothing currently built-in to resolve all destinations from the k8s API ahead of time.
An implementation for that would likely be similar to the built-in DNS resolver, just talking to the API instead.