Skip to content

Instantly share code, notes, and snippets.

@coderfi
Last active December 7, 2018 20:29
Show Gist options
  • Save coderfi/4a04aa666e0ff0db7e7416d1253f736d to your computer and use it in GitHub Desktop.
Save coderfi/4a04aa666e0ff0db7e7416d1253f736d to your computer and use it in GitHub Desktop.
Istio Gateway Host and Port discovery (minikube or cluster)
#!/usr/bin/env bash
# Usage:
# eval $(bash ./gateway-env.sh)
# Author: [email protected]
INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
if [[ "${INGRESS_HOST}" == "" ]]; then
# assume minikube
INGRESS_HOST=$(minikube ip)
INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
else
INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
fi
echo export INGRESS_HOST=$INGRESS_HOST
echo export INGRESS_PORT=$INGRESS_PORT
if [[ "${INGRESS_PORT}" != "80" ]]; then
echo export GATEWAY_URL=http://$INGRESS_HOST:$INGRESS_PORT
else
echo export GATEWAY_URL=http://$INGRESS_HOST
fi
@coderfi
Copy link
Author

coderfi commented Dec 7, 2018

Wrote this to find the ISTIO gateway url, whether it is minikube or a kubernetes cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment