You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Traefik IngressRoute会话粘性实现流量转发到同一个Pod

你只需要在现有IngressRoute的对应Service配置段中添加粘性会话相关配置即可,修改后的完整配置如下:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: demo-rr-camunda-bpm-platform-app-ingress-route1
  namespace: bpm
spec:
  entryPoints:
  - bpm
  routes:
  - kind: Rule
    match: PathPrefix(`/bpm/demo-rr-camunda-bpm-platform-app`)
    services:
    - kind: Service
      name: demo-rr-camunda-bpm-platform-app-service1
      port: 5000
      # 会话粘性配置
      sticky:
        cookie:
          name: bpm-sticky-session
          path: /bpm/demo-rr-camunda-bpm-platform-app
          secure: true
          httpOnly: true
  tls:
    secretName: k8s-code-ru-tls

配置说明:

  • 新增的sticky.cookie配置会让Traefik为首次访问的用户生成专属粘性Cookie,后续该用户的所有请求都会被转发到首次响应的Pod上,避免跨Pod导致的授权失败问题。
  • 你可以根据实际业务需求调整Cookie的名称、路径、安全属性等,也可以只保留cookie: {}使用默认配置。
  • 配置修改完成后直接更新集群中的IngressRoute资源即可立即生效。

内容的提问来源于stack exchange,提问作者Maksim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 03:54:05