上一篇的Bookinfo
这个服务中,我们有使用samples/bookinfo/networking/bookinfo-gateway.yaml
进行部署。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
spec:
hosts:
- "*"
gateways:
- bookinfo-gateway
http:
- match:
- uri:
exact: /productpage
- uri:
prefix: /static
- uri:
exact: /login
- uri:
exact: /logout
- uri:
prefix: /api/v1/products
route:
- destination:
host: productpage
port:
number: 9080
hosts
可以使用多组host name,主要是针对要导入VirtualService的host,需要设定在这边,像下图的例子,当host name为下面例子时才会导流进来。
VirtualService可以为IP或是DNS
hosts:
- "www.imtest.com"
- "www.imtest.net"
这边使用了http
是这区域定义了路由规则,match
表示要符合规则的才会导入到对应的服务。
exact: /productpage
: 绝对路径prefix: /static
: 前缀static的路径regex
: 使用正则式uri
,外还可以使用headers
来判断。route
: 当符合match
的路由条件时,VirtualService就会把流量导到host的服务http:
- match:
- uri:
exact: /productpage
- uri:
prefix: /static
- uri:
exact: /login
- uri:
exact: /logout
- uri:
prefix: /api/v1/products
- headers: ## header里面有end-user=jason
end-user:
exact: jason
route:
- destination:
host: productpage
port:
number: 9080
也可以写成一个VirtualService 多组路由规则,下面的路由规则设定了从bookinfo-gateway进来流量,透过不同的path导至不同的服务的需求。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
spec:
hosts:
- "*"
gateways:
- bookinfo-gateway
http:
- match:
- uri:
exact: /productpage1
route:
- destination:
host: productpage
port:
number: 9080
name: "route1"
- match:
- uri:
prefix: /static
route:
- destination:
host: productpage
port:
number: 9080
name: "route2"
- match:
- uri:
prefix: /test2
route:
- destination:
host: productpage2
port:
number: 9080
name: "route3"
以上是上面case中会用到的用法,如果需要更多的用法可以参考官网的文件喔
官方virtual-service
<<: [DAY 16]用bot打出色色柴犬counter牌
D29. C++字串 C++ string的特别用法 str.size():字串长度。 str.em...
key 是 React element 中的一个属性,相信很多人在撰写 React 的时候都会遇到下...
使用 salsa20 或 chacha20 或 chacha20-ietf 算法,需要安装 libs...
今天要介绍的 Tip 是有关於 pipe 的 pure 与 impure,当没有任何额外的设定下,自...
Button()方法有在前两天的时候提了一些,今天会更详细的介绍Buton()的使用方法 (o゜▽゜...