kubernetes - 基于 Istio 入口网关子域路由
问题描述
我有三个需要通过 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
解决方案
我猜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
推荐阅读
- java - 使用硒使用apache poi写入excel文件
- reactjs - Firebase deploy --only 托管不会更新 React.js webapp 内容,除非站点数据被清除
- php - How handle fatal error in "stale element reference: element is not attached to the page document" error in php-webdriver?
- python - 如何修复从烧瓶中的模型获取数据?
- c++ - Fail to compile: strlen is not a member of std
- java - Call a Scala "val function" from Java gives error
- wordpress - 拥有所有相关的 opengraph 社交元(由 AIOS 创建),但 facebook 调试无法识别
- gcloud - 谷歌云构建:设备上没有剩余空间
- python - 使用 numpy 的逐元素矩阵乘法(Hadamard 乘积)
- javascript - 为什么 Object 原型中没有与 Object 相关的方法?