gpt4 book ai didi

azure - 使用istio虚拟服务暴露3条路由

转载 作者:行者123 更新时间:2023-12-02 11:55:10 26 4
gpt4 key购买 nike

我们现在切换到 istio,我需要将我的应用程序公开给外部

在应用程序中,我只有 3 条路线

  1. "/" root route
  2. "/login"
  3. "static" - my app should serve some static files

我们有 gwhost 但不知何故我无法访问我的应用程序,知道我在这里做错了什么吗?vs-yaml

有没有办法公开所有路由,或者我应该显式定义它们,如果是这样的话,它与routesmatch有点混淆?

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bher-virtualservice
namespace: ba-trail
spec:
gateways:
- webb-system.svc.cluster.local
hosts:
- trialio.cloud.str
http:
- route:
- destination:
host: bsa
port:
number: 5000

最佳答案

if so how as it a bit confusing with routes and match

我建议查看有关 virtual services 的 istio 文档,那里描述得很好。

<小时/>

让我们从头开始,您有虚拟服务和网关,它们应该与您的应用程序位于同一命名空间中,或者您需要在两者中指定。

据我所知,您的虚拟服务不正确,我已经准备了适合您的示例。看看下面的例子。

网关

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: bher-gateway
namespace: ba-trail 👈
spec:
selector:
istio: ingressgateway # use the default IngressGateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "trialio.cloud.str"

我看到你有gateway它已经部署,如果它与虚拟服务不在同一命名空间中,您应该像下面的示例一样添加它。

检查spec.gateways部分

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: my-gateway
namespace: some-config-namespace
<小时/>
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo-Mongo
namespace: bookinfo-namespace
spec:
gateways:
- some-config-namespace/my-gateway # can omit the namespace if gateway is in same
namespace as virtual service.
<小时/>

虚拟服务

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bher-virtualservice
namespace: ba-trail 👈
spec:
gateways:
- bher-gateway 👈 // name of your gateway
hosts:
- trialio.cloud.str
http:
- match:
- uri:
prefix: "/"
- uri:
prefix: "/login"
- uri:
prefix: "/static"
- uri:
regex: '^.*\.(ico|png|jpg)$'
route:
- destination:
host: bsa.ba-trail.svc.cluster.local 👈 // name_of_your service.namespace.svc.cluster.local
port:
number: 5000

看看这个 example

Let’s break down the requests that should be routed to Frontend:

Exact path / should be routed to Frontend to get the Index.html

Prefix path /static/* should be routed to Frontend to get any static files needed by the frontend, like Cascading Style Sheets and JavaScript files.

Paths matching the regex ^.*.(ico|png|jpg)$ should be routed to Frontend as it is an image, that the page needs to show.

http:
- match:
- uri:
exact: /
- uri:
exact: /callback
- uri:
prefix: /static
- uri:
regex: '^.*\.(ico|png|jpg)$'
route:
- destination:
host: frontend
port:
number: 80
<小时/>

希望您觉得这很有用。如果您有任何疑问,请在评论中告诉我。

关于azure - 使用istio虚拟服务暴露3条路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62997054/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com