简体   繁体   中英

User specific routing in Istio / Kuberentes

I'm wondering if Istio is a good tool to support a particular routing situation, and if not (or even if it is), what other approaches are available.

  • I have two microservices, X and Y, with have some number of replicas for each.
  • X sends requests to Y.
  • X sends requests as a particular user, say "bob".
  • Some subset of the replicas of Y (not all!) can handle requests for the user "bob".
  • The subset of Y that can handle requests for "bob" is not static but changes over-time depending on some state stored at a replica that is ephemeral.

So when X sends requests, it must determine for the user it is sending the request ("bob"), which subset of Y can that particular request be sent to?

In Istio, there are examples of a routing rule that is associated with a user by looking at the HTTP headers. For the sever side, Y, would I simply have code in Y that calls the k8s API to add and remove labels against the replicas Pod?

eg,

Service-Y.Pod-1.Labels = {
  "user-bob": "true",
  "user-jane": "true",
  ...
}

Unclear how well labels handle this, or if this kind of routing should be lifted up to the application layer rather than trying to encode it in a largely transparent service mesh layer.

You have the open API from K8s. You can make some code which will add a label to pods and then route this traffic to your pods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM