Reputation: 1023
We switch now to istio and I need to expose my app to outside
In the app, I've only 3 routes
- "/" root route
- "/login"
- "static" - my app should serve some static files
we have gw
and host
but somehow I cannot access my app, any idea what am I doing wrong here?
vs-yaml
is there a way to expose all the routes, or should I define them explicitly, if so how as it a bit confusing with routes
and match
?
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
Upvotes: 1
Views: 1407
Reputation: 8830
if so how as it a bit confusing with routes and match
I would suggest to take a look at istio documentation about virtual services, it's well described there.
Let's start from the beginning, you have virtual service and gateway, they should be in the same namespace as your application, or you need to specify that in both of them.
As far as I can see your virtual service is incorrect, I have prepared example which should work for you. Take a look at below example.
Gateway
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"
I see you have gateway which is already deployed, if itΒ΄s not in the same namespace as virtual service, you should add it like in below example.
Check the spec.gateways
section
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.
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
Take a look at this 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
Hope you find this useful. If you have any questions let me know in the comments.
Upvotes: 2
Reputation: 186
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bher-virtualservice
namespace: ba-trail
spec:
gateways:
- webb-system.svc.cluster.local. #### don't look right , can write the gateway name only here. ####
hosts:
- trialio.cloud.str
http:
- route:
- destination:
host: bsa
port:
number: 5000 ## is your service working on this port
- rewrite: #### this should not be an issue but you can try adding this too
uri: /
Upvotes: 1