如何在路由器中为 Istio Ingress 网关配置传入端口
How configure incoming port in router for Istio Ingress gateway
我尝试使用 openshift 路由配置 istio ingress。据我了解请求路径如下:
request -> route -> ingress service -> gateway -> virtual service -> app service -> app
所以,我应用了以下配置:
Route.yml:
kind: Route
...
spec:
host: my-app.com
to:
kind: Service
name: ingress-service
weight: 100
port:
targetPort: http
...
入口-service.yml:
kind: Service
metadata:
name: ingress-service
...
spec:
ports:
- name: status-port
protocol: TCP
port: 15020
targetPort: 15020
- name: http
protocol: TCP
port: 9080
targetPort: 9080
selector:
app: ingressgateway
istio: ingressgateway
type: ClusterIP
入口-gateway.yml:
kind: Gateway
metadata:
name: ingress-gw
...
spec:
servers:
- hosts:
- my-app.com
port:
name: http
number: 9080
protocol: HTTP
selector:
istio: ingressgateway
入口-虚拟-service.yml
kind: VirtualService
...
spec:
hosts:
- my-app.com
gateways:
- ingress-gw
http:
- route:
- destination:
host: my-app
port: 9080
exportTo:
- .
我没有在 ingressgateway pod 的部署中设置端口 9080。它有效。但只有当我向 http://my-app.com:80
发送请求时
我哪里出错了,如何让只有路径可以访问http://my-app.com:9080?
外部公开的端口号取决于 OpenShift 上的 Router(HAProxy) pod 侦听端口。如果你想要 9080 端口而不是 80,你应该更改 Router(HAProxy) pod 上的端口。或者你可以在LB上处理端口号使用其他端口号。
访问流程如下
LB(80, 443)
-> Router pod(80, 443)
-> Ingress-Gateway pod
-Through Gateway and VirtualService -> Backend pod
我尝试使用 openshift 路由配置 istio ingress。据我了解请求路径如下:
request -> route -> ingress service -> gateway -> virtual service -> app service -> app
所以,我应用了以下配置:
Route.yml:
kind: Route
...
spec:
host: my-app.com
to:
kind: Service
name: ingress-service
weight: 100
port:
targetPort: http
...
入口-service.yml:
kind: Service
metadata:
name: ingress-service
...
spec:
ports:
- name: status-port
protocol: TCP
port: 15020
targetPort: 15020
- name: http
protocol: TCP
port: 9080
targetPort: 9080
selector:
app: ingressgateway
istio: ingressgateway
type: ClusterIP
入口-gateway.yml:
kind: Gateway
metadata:
name: ingress-gw
...
spec:
servers:
- hosts:
- my-app.com
port:
name: http
number: 9080
protocol: HTTP
selector:
istio: ingressgateway
入口-虚拟-service.yml
kind: VirtualService
...
spec:
hosts:
- my-app.com
gateways:
- ingress-gw
http:
- route:
- destination:
host: my-app
port: 9080
exportTo:
- .
我没有在 ingressgateway pod 的部署中设置端口 9080。它有效。但只有当我向 http://my-app.com:80
发送请求时我哪里出错了,如何让只有路径可以访问http://my-app.com:9080?
外部公开的端口号取决于 OpenShift 上的 Router(HAProxy) pod 侦听端口。如果你想要 9080 端口而不是 80,你应该更改 Router(HAProxy) pod 上的端口。或者你可以在LB上处理端口号使用其他端口号。
访问流程如下
LB(80, 443)
-> Router pod(80, 443)
-> Ingress-Gateway pod
-Through Gateway and VirtualService -> Backend pod