[英]cookie-based virtual service routing does not work
We followed the instruction https://istio-releases.github.io/v0.1/docs/concepts/traffic-management/rules-configuration.html to setup routing rule based on a cookie.我们按照指令https://istio-releases.github.io/v0.1/docs/concepts/traffic-management/rules-configuration.ZFC35FDC70D5FC69D269883A8222222基于a cookie.5 设置路由规则到AZC7
There is the actual istio virtual service configuration:有实际的 istio 虚拟服务配置:
apiVersion: networking.istio.io/v1beta1 api版本:networking.istio.io/v1beta1
kind: VirtualService种类:虚拟服务
metadata:元数据:
annotations:注释:
meta.helm.sh/release-name: prodstagingistio
meta.helm.sh/release-namespace: istio-system
creationTimestamp: "2022-07-14T16:12:56Z"创建时间戳:“2022-07-14T16:12:56Z”
generation: 22世代:22
labels:标签:
app.kubernetes.io/managed-by: Helm
name: api-gateway-virtualservice名称:api-gateway-virtualservice
namespace: istio-system命名空间:istio-system
resourceVersion: "149056406"资源版本:“149056406”
uid: a5be0a58-6fd8-467c-9a98-5de9ac71b1dd用户名:a5be0a58-6fd8-467c-9a98-5de9ac71b1dd
spec:规格:
gateways:网关:
hosts:主持人:
api0-prod.dev.domain.com api0-prod.dev.domain.com
api0-staging.dev.domain.com api0-staging.dev.domain.com
http: http:
match:匹配:
authority:权威:
exact: api0-prod.dev.domain.com准确:api0-prod.dev.domain.com
headers:标题:
cookie:曲奇饼:
regex: ^(.*;.)?(feature-b=true)(;.*)?$
route:路线:
destination:目的地:
host: api-gateway.blue.svc.cluster.local主机:api-gateway.blue.svc.cluster.local
match:匹配:
authority:权威:
exact: api0-prod.dev.domain.com准确:api0-prod.dev.domain.com
route:路线:
destination:目的地:
host: api-gateway.green.svc.cluster.local主机:api-gateway.green.svc.cluster.local
match:匹配:
authority:权威:
exact: api0-staging.dev.domain.com准确:api0-staging.dev.domain.com
route:路线:
destination:目的地:
host: api-gateway.orange.svc.cluster.local主机:api-gateway.orange.svc.cluster.local
Supposedly, when accessing https://api0-prod.dev.domain.com with cookie value (feature-b=true) in http header, the traffic should be redirected to api-gateway.blue.svc.cluster.local. Supposedly, when accessing https://api0-prod.dev.domain.com with cookie value (feature-b=true) in http header, the traffic should be redirected to api-gateway.blue.svc.cluster.local. But regardless of the cookie setting, the traffic was sent to api-gateway.green.svc.cluster.local.但无论 cookie 设置如何,流量都会发送到 api-gateway.green.svc.cluster.local。
But I can't find anything wrong according to the document.但是根据文档我找不到任何问题。
Can anything help taking a look of the config and see why the cookie setting doesn't work?有什么可以帮助查看配置并了解为什么 cookie 设置不起作用?
The virtual service routes should be like below to match cookie.虚拟服务路由应如下所示以匹配 cookie。 Similarly you need to add for green.同样,您需要添加绿色。
http:
- match:
- headers:
cookie:
regex: ^(.*;.)?(feature-b=true)(;.*)?$
route:
- destination:
host: api-gateway.blue.svc.cluster.local
subset: blue-sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.