Get istio gateway url

132 Views Asked by At

Run example

k apply -f https://raw.githubusercontent.com/antonputra/tutorials/main/lessons/155/3-example/6-gateway.yaml

How to access istio gateway from localhost?

Tried

export INGRESS_HOST=$(kubectl get gateway  api -o jsonpath='{.status.addresses[0].value}')
export INGRESS_PORT=$(kubectl get gateway  api  -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
curl -s -I -HHost:app.devopsbyexample.com "http://$INGRESS_HOST:$INGRESS_PORT"

However INGRESS_HOST is empty as

kubectl get gateway  api -o jsonpath='{.status.addresses[0].value}'

empty as well

2

There are 2 best solutions below

0
Srividya On

To access an Istio Gateway from your localhost using curl, you need to set INGRESS_HOST and INGRESS_PORT variables.

The environment variables you have set doesnt contain the <gateway name>. Try adding the gateway name and set the variables.

$ export INGRESS\_HOST=$(kubectl get gateway <gateway-name\> -o jsonpath=’{.status.addresses[0].value}’

$ export INGRESS\_PORT = $(kubect get gateway <gateway-name\> -o jsonpath=’{.spec.listeners[?(@.name==”http”)].port}’

Replace the with the name of your Istio gateway. These commands retrieve the external IP or domain address and the port number assigned to the Istio Gateway and set them as the values of the INGRESS_HOST and INGRESS_PORT variables respectively.

Now you can access the Istio Gateway using curl.

Curl -s -I -HHost:app.devopsbyexample.com "http://$INGRESS\_HOST:$INGRESS\_PORT"

Make sure app.devopsbyexample.com is the desired hostname or the domain that matches the routing rules defined in your Istio Gateway configuration.

By setting these variables and using curl, you can access the Istio Gateway from your local host.

0
Yilmaz Guleryuz On

You can access via istio-ingressgateway

you can get IP & PORT for istio-ingressgateway like this

# display gw IP  
kubectl -n istio-system get svc/istio-ingressgateway -o yaml | grep loadBalancer -A4    

# display gw http port  
kubectl -n istio-system get svc/istio-ingressgateway -o yaml | grep http2 -A4  

# display gw https port  
kubectl -n istio-system get svc/istio-ingressgateway -o yaml | grep https -A4

then you can use this IP & PORT to access your services.

notice that you configure gateway, which is inter-connected via virtualservice see istio docs for more info.