dotnet / tye

Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
MIT License
5.28k stars 520 forks source link

Add the ability to query addresses of replicas in the list of services #356

Open davidfowl opened 4 years ago

davidfowl commented 4 years ago

What should we add or change to make your life better?

Add the ability to get the addresses of replicas within the list of services.

Why is this important to you?

Some distributed algorithms require knowing what replicas exists so that pods/nodes can communicate between each other (membership algorithms etc).

This is also useful when trying to build out something like a client load balancer that wants to send traffic to individual replicas instead of being routed through the proxy.

JamesNK commented 4 years ago

I want this to support lookaside loading balancing in the gRPC client. I need to know the underlying addresses of replicas to call them directly.

Storing addresses in an environment variable would work for tye run at the replica IPs won't change, but Kubernetes pods and their addresses can change at runtime. Because we want a solution that works in both scenarios, relying completely on environment variables won't work.

In Kubernetes the replica IPs are resolved from DNS A records returned by Dns.GetHostAddressesAsync(host). Apps periodically poll for changes to get updates.

An idea for a consistent API:

public interface IAddressResolver
{
    Task<IList<string>> GetAddresses(string service);
}

internal class DefaultAddressResolver : IAddressResolver
{
    public DefaultAddressResolver(IConfiguration configuration) {}
    public Task<IList<string>> GetAddresses(string service) {}
}

The implementation use environment variables to determine whether it is running locally or in Kubernetes.

JamesNK commented 4 years ago

Related, how would you configure a headless service in tye.yaml? e.g. a Kubernetes service with clusterIP: None

abbottdev commented 2 years ago

I would like this to be able to also support Orleans services, where each Orleans silo needs to be able to communicate with another. There's an in-built clustering provider for Kubernetes, but this would only function once deployed.

WoLfulus commented 2 years ago

I would like this to be able to also support Orleans services, where each Orleans silo needs to be able to communicate with another. There's an in-built clustering provider for Kubernetes, but this would only function once deployed.

Same situation here.