【发布时间】:2020-02-04 08:25:27
【问题描述】:
我正在尝试使用 istio 虚拟服务进行反向代理
可以在虚拟服务中转发请求吗? (像 nginx 的 proxy_pass)
结果,
- http://myservice.com/about/* -> 将请求转发到 CDN(k8s 系统外的外部服务 - aws s3 等......)
- http://myservice.com/* -> my-service-web(内部服务包含在 istio 网格中)
定义了服务入口,但它只是“重定向”,而不是转发请求。
这是我的 serviceentry.yaml 和 virtualservice.yaml
- serviceentry.yaml
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: my-service-proxy
namespace: my-service
spec:
hosts:
- CDN_URL
location: MESH_EXTERNAL
ports:
- number: 80
name: http
protocol: HTTP
- number: 443
name: https
protocol: TLS
resolution: DNS
- virtualservice.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: my-service
namespace: my-service
spec:
hosts:
- myservice.com
gateways:
- myservice
http:
- match:
- uri:
prefix: /about
rewrite:
authority: CDN_URL
uri: /
route:
- destination:
host: CDN_URL
- route:
- destination:
host: my-service-web.svc.cluster.local
port:
number: 80
virtualservice 可以像 nginx-igress 一样工作吗?
【问题讨论】:
标签: kubernetes istio