Replies: 1 comment
-
Hey @rng2, great questions :) I'll try to answer them as concretely as possible, this is all based on my understanding of headless services after working with them for a while. Background: in Kubernetes, most workloads are deployed as a set of pods. These usually tend to be ephemeral, which makes the management of IP addresses at higher levels of abstraction a bit of a nightmare to deal with. To work around this, we have Headless services are an exception to the rule, and are primarily used with Load balancing and service discovery: let's say a client A sends a request to a server B. Both of them are injected and in the mesh. Client A sends a request to Now, if you work with headless services, the situation is a bit different. Say Multicluster: it's true that in some distributions you can take advantage of a flat network topology and have access to any IP address, but we don't make that assumption. Multicluster should work for any arbitrary cluster topology imo, so it makes more sense to go through a gateway. We also embed the gateway's identity in the mirror endpoints so we can do TLS. It wouldn't be a problem I suppose to do that for pods, but it would just again introduce a lot of complexity.
Generally, I think if you have a headless service, it means you want to control yourself which pod to send traffic to. This is more of an assumption k8s makes and we went along with. If you want to let your service mesh take over load balancing, or do load balancing implicitly through k8s' Let me know if you have any questions. You can read through the research we have done on headless services and multicluster in #5162 (comment) which might be a bit more helpful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I’ve been researching how linkerd (and service meshes in general) works with k8s headless services, and have some questions. Apologies beforehand if I miss any design constraints. I’m fairly new to the whole k8s + service mesh space.
First one is about multi-cluster. According to this blog post, multi-cluster-kubernetes-with-headless-services, when routing to a headless service in a remote cluster (say R), traffic has to first go through a dedicated gateway in R. This is because the mirrored Endpoints configure the gateway’s IP as the destination. Is this a fundamental requirement? Afaik, in certain k8s setups like GKE, pod IPs are first-class and are natively routable from anywhere within the VPC. So it seems that having each mirrored Endpoint points directly to its corresponding remote pod should work, in which case we save an extra hop. Is this design possible (assuming the context)? Or maybe we then lose out on some features that require going through the gateway?
Second question is also about headless services, but within a single cluster. The linkerd doc on load balancing states this:
Istio has the same constraint afaik. Again, is this a fundamental limitation with service meshes and k8s? Assuming the sidecar proxy on the client pod can utilize dns for service discovery, it seems that it should be able to retrieve the IPs of all the pods backing the headless service, and then do client-side load balancing between these IPs. I saw this approach mentioned in several blog posts on how to load balance grpc services in k8s in a non-service-mesh world. In fact linkerd is doing the same thing for grpc from my understanding; it just doesn’t support headless services.
Or if this is not possible (maybe the dns step doesn’t work the way I think), can we do something similar to what the Endpoint-mirroring controller for multi-cluster does? If it can discover/mirror all headless service Endpoints from a remote cluster, can’t the same logic be used for a local service? When the doc says
what exact part of k8s makes it so?
Or if the problem is that the proxy cannot tell whether the client pod wants to load balance between target pod IPs or to route directly to one at random, is it possible to add a mechanism that lets the client announce its “intent” to linkerd?
Beta Was this translation helpful? Give feedback.
All reactions