问题描述
这是我的虚拟服务目前的样子 -
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
Metadata:
name: example-route
spec:
hosts:
- example.com
http:
- match:
- port: 443
- uri:
prefix: "/catalog"
route:
- destination:
host: catalog-server.ns.svc.cluster.local
- match:
- port: 443
route:
- destination:
host: general-server.ns.svc.cluster.local
我想要的是在虚拟服务/istio 中为目标主机(catalog-server.ns.svc.cluster.local)设置回退或默认主机?
我期待这样的事情
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
Metadata:
name: example-route
spec:
hosts:
- example.com
http:
- match:
- port: 443
- uri:
prefix: "/catalog"
route:
- destination:
host: catalog-server.ns.svc.cluster.local
fallback:
host: general-server.ns.svc.cluster.local
- match:
- port: 443
route:
- destination:
host: general-server.ns.svc.cluster.local
用例: 当“/catalog”流量大时,我打开一个目录服务器,它与一般服务器相同,但为请求类型专用。 所以当目录服务器启动时,“/catalog”请求必须转发到目录服务器,当关闭时,它必须转发到通用服务器。每次启动或删除目录服务器时,我都无法更新虚拟服务。
解决方法
Istio 确实为 https://istio.io/latest/docs/tasks/traffic-management/circuit-breaking/
中所述的熔断提供了一些支持但是,afaik 不支持回退。这可能意味着如果主服务关闭,应用程序将不得不调用回退。