istio Ingress Gateway

除了支持 Kubernetes Ingress,Istio还提供了另一种配置模式,Istio Gateway。与 Ingress 相比,Gateway 提供了更广泛的自定义和灵活性,并允许将 Istio 功能(例如监控和路由规则)应用于进入集群的流量。

 参考:https://istio.io/latest/zh/docs/tasks/traffic-management/ingress/ingress-control/

vs和gw之间关联

1、创建 Istio Gateway

kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: httpbin-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "httpbin.example.com"
EOF

2、为通过 Gateway 的入口流量配置路由:

kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
  - "httpbin.example.com"
  gateways:
  - httpbin-gateway
  http:
  - match:
    - uri:
        prefix: /status
    - uri:
        prefix: /delay
    route:
    - destination:
        port:
          number: 8000
        host: httpbin
EOF

已为 httpbin 服务创建了Virtual Service配置,包含两个路由规则,允许流量流向路径 /status 和 /delay

 

 

来自网格内部其他服务的内部请求无需遵循这些规则,而是默认遵守轮询调度路由规则。您可以为 gateways 列表添加特定的 mesh 值,将这些规则同时应用到内部请求。由于服务的内部主机名可能与外部主机名不一致(譬如:httpbin.default.svc.cluster.local),您需要同时将内部主机名添加到 hosts 列表中。

 

路由规则没有对 ingress gateway 请求生效:https://istio.io/latest/zh/docs/ops/common-problems/network-issues/#route-rules-have-no-effect-on-ingress-gateway-requests

 

 

posted @ 2022-03-30 17:03  JvvYou  阅读(556)  评论(0编辑  收藏  举报