ConflictingMeshGatewayVirtualServiceHosts
當 Istio 偵測到虛擬服務資源之間存在衝突重疊時,就會出現此訊息。例如,如果定義了多個虛擬服務使用相同的主機名稱並連接到網格閘道,就會產生錯誤訊息。請注意,Istio 支援合併連接到入口閘道的虛擬服務。
解決方案
要解決此問題,您可以採取以下其中一項措施
- 將衝突的虛擬服務合併成單一資源。
- 使連接到網格閘道的虛擬服務之間的主機名稱保持唯一。
- 透過設定
exportTo
欄位將資源範圍限定於特定命名空間。
範例
命名空間 team1
中的 productpage
虛擬服務與 team2
命名空間中的 custom
虛擬服務衝突,因為以下兩者皆為真:
- 它們都連接到預設的 “mesh” 閘道,因為沒有指定自訂閘道。
- 它們都定義了相同的主機
productpage.default.svc.cluster.local
。
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: productpage
namespace: team-1
spec:
hosts:
- productpage.default.svc.cluster.local
http:
- route:
- destination:
host: productpage
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: custom
namespace: team-2
spec:
hosts:
- productpage.default.svc.cluster.local
http:
- route:
- destination:
host: productpage.team-2.svc.cluster.local
---
您可以透過將 exportTo
欄位設定為 .
來解決此問題,以便每個虛擬服務的範圍僅限於其自己的命名空間。
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: productpage
namespace: team-1
spec:
exportTo:
- "."
hosts:
- productpage.default.svc.cluster.local
http:
- route:
- destination:
host: productpage
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: custom
namespace: team-2
spec:
exportTo:
- "."
hosts:
- productpage.default.svc.cluster.local
http:
- route:
- destination:
host: productpage.team-2.svc.cluster.local
---