簡體   English   中英

istio 虛擬服務重寫無法正常工作

[英]istio virtualservice rewrite not working properly

我已經在https://aws.amazon.com/blogs/containers/secure-end-to-end-traffic-on-amazon-eks-using-tls-certificate-in-acm-之后設置了 EKS + istio 入口網關alb-and-istio/並且工作正常。 我想在 virtualservice 中添加 uri 前綴,這樣http://domain.tld/vote需要顯示在集群中另一個命名空間中創建的投票應用程序。

我使用了以下 istio 虛擬服務。 https://domain.tld工作正常,但https://domain.tld/vote顯示布局損壞。 截圖: https://i.is.cc/1ah4YkVU.png

這是我用於投票服務的投票應用程序 - https://github.com/dockersamples/example-voting-app ,它使用多個容器。 有人可以對此有所了解嗎?

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: yelb-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
    - port:
        number: 443
        name: https-443
        protocol: HTTPS
      tls:
        mode: SIMPLE
        credentialName: "tls-secret"
      hosts:
        - "*"
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: vote
spec:
  hosts:
    - "*"
  gateways:
    - yelb-gateway
  http:
  - match:
    - uri:
        prefix: /vote
    rewrite:
      uri: "/"
    route:
    - destination:
        host: vote.vote2.svc.cluster.local
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: yelb-ui
spec:
  hosts:
    - "*"
  gateways:
    - yelb-gateway
  http:
    - route:
        - destination:
            host: yelb-ui
            port:
              number: 80
      match:
        - uri:
            prefix: /

沒有重寫規則, http://domain.tld/vote顯示 404 錯誤。 使用上述重寫規則,url 正在加載但布局已損壞。

您可以像下面這樣使用一個虛擬服務而不是兩個。 作為服務 5000 中定義的端口號,您可以在虛擬服務中提及相同的端口號。 同樣在服務定義中,您可以將類型用作“ClusterIP”而不是 NodePort。 並在您的服務定義中添加“協議:TCP”。

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: vote
spec:
  hosts:
    - "*"
  gateways:
    - yelb-gateway
  http:
  - match:
    - uri:
        prefix: /vote    
    route:
    - destination:
        host: vote.vote2.svc.cluster.local 
        port:
          number: 5000
    - uri:
        prefix: /    
    route:
    - destination:
        host: yelb-ui.default.svc.cluster.local
        port:
          number: <yelb-service-port-number>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM