如何在Openshift3中禁用粘性会话 [英] How to disable sticky sessions in Openshift3

查看:107
本文介绍了如何在Openshift3中禁用粘性会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在Openshift3中扩展Pod,则来自同一客户端IP地址的所有请求都将发送到与会话相关联的容器。

If you scale up a Pod in Openshift3, all requests coming from the same client IP address are sent to container which has the session associated.

是否有任何配置可禁用粘性会话?如何在Openshift中管理内部HAProxy的选项?

Is there any configuration to disable sticky sessions? How can I manage the options of internal HAProxy in Openshift?

推荐答案

对于后代,由于我有同样的问题,我想记录一下我从Graham Dumpleton的出色评论。

For posterity, and since I had the same problem, I want to document the solution I used from Graham Dumpleton's excellent comment.

事实证明,在第一个将后续请求重定向到同一后端的请求。要基于每个路由禁用此行为:

As it turns out, a cookie is set during the first request that redirects subsequent requests to the same back-end. To disable this behavior on a per-route basis:

oc annotate routes myroute haproxy.router.openshift.io/disable_cookies='true'

这可以防止设置cookie并允许余额算法选择适当的后端来自同一客户的后续请求。要更改平衡算法:

This prevents the cookie from being set and allows the balance algorithm to select the appropriate back-end for subsequent requests from the same client. To change the balance algorithm:

oc annotate routes myroute haproxy.router.openshift.io/balance='roundrobin'

设置了这两个注释后,来自同一客户端IP地址的请求将依次发送到每个后端一遍又一遍的相同后端。

With these two annotations set, requests from the same client IP address are sent to each back-end in turn, instead of the same back-end over and over.

这篇关于如何在Openshift3中禁用粘性会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆