【问题标题】:Istio ingress gateway subdomainrouting based基于 Istio 入口网关子域路由
【发布时间】:2021-08-10 15:15:33
【问题描述】:

我需要通过 istio 入口网关公开三个服务,我已将这些服务的 dns 记录设置为指向入口网关负载均衡器,但我没有成功使其工作。

网关和虚拟服务配置文件:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: test-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*.mywebsite.io"


    
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: virtualservice
spec:
  hosts:
  - "*.mywebsite.io"
  gateways:
  - test-gateway
  http:
  - name: "api-gateway"
    match:
    - uri:
        exact: "gateway.mywebsite.io"
    route:
      - destination:
           host: gateway.default.svc.cluster.local
           port:
             number: 8080
  - name: "visitor-service"
    match:
    - uri:
        exact: "visitor-service.mywebsite.io"
    route:
      - destination:
           host: visitor-service.default.svc.cluster.local
           port:
             number: 8000
  - name: "auth-service"
    match:
    - uri:
        exact: "auth-service.mywebsite.io"
    route:
      - destination:
           host: auth-service.default.svc.cluster.local
           port:
             number: 3004  

     

【问题讨论】:

    标签: kubernetes istio istio-gateway


    【解决方案1】:

    我猜HttpMatchRequest 的 URI 部分不能这样工作。尝试为每个子域添加 VirtualServices,即类似的东西。

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: gateway-virtualservice
    spec:
      hosts:
      - "gateway.mywebsite.io"
      gateways:
      - test-gateway
      http:
      - name: "api-gateway"
        match:
        - uri:
            exact: "/" #or prefix
        route:
          - destination:
               host: gateway.default.svc.cluster.local
               port:
                 number: 8080
    ---
    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: visitor-virtualservice
    spec:
      hosts:
      - "visitor-service.mywebsite.io"
      gateways:
      - test-gateway
      http:
      - name: "visitor-service"
        match:
        - uri:
            exact: "/"
        route:
          - destination:
               host: visitor-service.default.svc.cluster.local
               port:
                 number: 8000
    

    【讨论】:

    • 谢谢兄弟,我被封了两个星期,现在可以了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-09
    • 2023-01-18
    • 2021-01-08
    • 2023-01-12
    • 2021-07-12
    • 2021-12-14
    • 1970-01-01
    相关资源
    最近更新 更多