Istio http流量管理
在Kubernetes中 service 和 Deployment 或者其他负载的关系通常是 一对一 的,
而在Istio中,Service经常会对应不同的 Deployment。
Istio 主要通过 DestinationRule 和 VirtualService 来实现该功能,可以简单理解成将原始的 Kubernetes service 拆成了两个单独的部分
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: nginx-default-v2
namespace: lizhe
spec:
hosts:
- nginx-service //(Kubernetes service name)
http:
- route:
- destination:
host: nginx-service
subset: v2
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: nginx-desrule
namespace: lizhe
spec:
host: nginx-service //(Kubernetes service name)
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
- name: v3
labels:
version: v3
多个 host 的例子
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
gateways:
- bookinfo-gateway
- mesh
http:
- match:
- headers:
end-user:
exact: jason
route:
- destination:
host: reviews
subset: v2
- route:
- destination:
host: reviews
subset: v3