0

Scenario: I have 2 clients. let's say client A and client B. Both clients have one common id (like UUID). My application(it's c++) is configured like both the clients have to connect in one server.

I am planning to add (AWS)ELB/nginx in front of my application. So Problem is when we received a request from client A it will pass through ELB and connect in one of the nodes. When client B sends the request to ELB then I am not sure that it will connect to the same node where client A is connected. Client B should connect on that node where Client A was connected.

在我的场景中,两个客户端都应该连接到同一个节点。 客户总是以一个共同的 ID 成对出现。在这种情况下应该使用什么?

我的应用程序是 dockerized,我正在使用 kubenetes 进行部署。

4

1 回答 1

0

您可以配置您的Nginx Ingress Controller并使用annotation

nginx.ingress.kubernetes.io/server-snippet

Ingress可能如下所示:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/server-snippet: |
 set $agentflag 0;

 if ($http_user_agent ~* "(Mobile)" ){
 set $agentflag 1;
 }

 if ( $agentflag = 1 ) {
 return 301 https://m.example.com;
 }

请在 Github 上查看有关 ingress-nginx 注释的更详细说明。

如果您有多个节点,您可以POD使用Node affinity. 这也可以通过使用nodeSelectorwhich 是Node affinity.

于 2019-01-22T10:29:04.097 回答