简体   繁体   English

Traefik IngressRoute。 如何将流量仅引导到一个 pod?

[英]Traefik IngressRoute. How to direct traffic to only one pod?

I have an ingressroute configuration:我有一个 ingressroute 配置:

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
  tls:
    secretName: k8s-code-ru-tls

With this configuration, if two replicas are running, when you try to request a login, the page is displayed from one pod, and the authorization attempt flies to the other pod (and does not work).使用此配置,如果两个副本正在运行,当您尝试请求登录时,页面会从一个 pod 显示,并且授权尝试会飞到另一个 pod(并且不起作用)。 It is necessary that both the login page and the authorization URL work on the same pod.登录页面和授权 URL 必须在同一个 pod 上工作。

If I'm not mistaken, then the solution to this problem is to use Stickiness https://doc.traefik.io/traefik/routing/services/如果我没记错的话,那么解决这个问题的方法就是使用Stickiness https://doc.traefik.io/traefik/routing/services/

If so, then I cannot figure out how to apply this code to the existing ingressroute that I described above:如果是这样,那么我无法弄清楚如何将此代码应用于我上面描述的现有 ingressroute:

## Dynamic configuration
http:
  services:
    my-service:
      loadBalancer:
        sticky:
         cookie: {}

you should use kubernetes service which will track your deployment (with 2 replicas) using labels.您应该使用 kubernetes 服务,该服务将使用标签跟踪您的部署(带有 2 个副本)。 the service will do the job for you, and Ingressroute will serve the two replicas该服务将为您完成工作,Ingressroute 将为两个副本提供服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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