kubernetes - 是否可以为虚拟服务中的路由目的地设置后备?
问题描述
这是我的虚拟服务目前的样子 -
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-break/
但是,afaik 不支持后备。这可能意味着如果主服务关闭,应用程序将不得不调用回退。