Istio GatewayIngress

步骤:

  1. 创建Gateway
  2. 创建VirtualService

样例文件

gateway.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: www-test-io
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "www.test.io"

virtualserver.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginx
spec:
  hosts:
  # 建议为*,后期如果接入其他域名,只需要修改gateway里面的hosts值就可以
  - "*"
  gateways:
  - www-test-io
  http:
  - match:
    - uri:
        # 相应的路径需要在后端存在,不然就会404,这也算是缺点之一吧,不能自定义加URL的路径
        prefix: /
    route:
    - destination:
        port:
          number: 8080 # svc port
        host: nginx.default.svc.cluster.local # svc FQDN name