Skip to content

Instantly share code, notes, and snippets.

@lucasponce
Created April 23, 2021 07:31
Show Gist options
  • Save lucasponce/95f2d6ec8fd81eec32aec3102ef073e6 to your computer and use it in GitHub Desktop.
Save lucasponce/95f2d6ec8fd81eec32aec3102ef073e6 to your computer and use it in GitHub Desktop.
Installation of Istio + Addons on GCP
export PROJECT_ID=`gcloud config get-value project` && \
export M_TYPE=n1-standard-2 && \
export ZONE=us-west2-a && \
export CLUSTER_NAME=${PROJECT_ID}-${RANDOM} && \
gcloud services enable container.googleapis.com && \
gcloud container clusters create $CLUSTER_NAME \
--cluster-version latest \
--machine-type=$M_TYPE \
--num-nodes 4 \
--zone $ZONE \
--project $PROJECT_ID
cd $ISTIO_HOME
istioctl install --set profile=demo -y
kubectl label namespace default istio-injection=enabled
kubectl apply -f ${ISTIO_HOME}/samples/bookinfo/platform/kube/bookinfo.yaml
while [[ $(kubectl get pods -l app=ratings -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]
do
echo "waiting for ratings pod"
kubectl get pods
sleep 60
done
kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"
cd $ISTIO_HOME
kubectl apply -f ${ISTIO_HOME}/samples/bookinfo/networking/bookinfo-gateway.yaml
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo "Update your local DNS with the public Ingress IP"
echo "sudo vi /etc/hosts"
echo "${INGRESS_HOST} bookinfo.istio-cluster.org"
echo "${INGRESS_HOST} kiali.istio-cluster.org"
echo "${INGRESS_HOST} grafana.istio-cluster.org"
echo "${INGRESS_HOST} tracing.istio-cluster.org"
echo "${INGRESS_HOST} control.travel-control.istio-cluster.org"
echo "Open http://bookinfo.istio-cluster.org/productpage"
cd $ISTIO_HOME
kubectl apply -f ${ISTIO_HOME}/samples/addons
export INGRESS_DOMAIN="istio-cluster.org"
cat <<EOF | kubectl apply -f -
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: kiali-gateway
namespace: istio-system
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http-kiali
protocol: HTTP
hosts:
- "kiali.${INGRESS_DOMAIN}"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: kiali-vs
namespace: istio-system
spec:
hosts:
- "kiali.${INGRESS_DOMAIN}"
gateways:
- kiali-gateway
http:
- route:
- destination:
host: kiali
port:
number: 20001
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: kiali
namespace: istio-system
spec:
host: kiali
trafficPolicy:
tls:
mode: DISABLE
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: grafana-gateway
namespace: istio-system
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http-grafana
protocol: HTTP
hosts:
- "grafana.${INGRESS_DOMAIN}"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: grafana-vs
namespace: istio-system
spec:
hosts:
- "grafana.${INGRESS_DOMAIN}"
gateways:
- grafana-gateway
http:
- route:
- destination:
host: grafana
port:
number: 3000
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: grafana
namespace: istio-system
spec:
host: grafana
trafficPolicy:
tls:
mode: DISABLE
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: tracing-gateway
namespace: istio-system
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http-tracing
protocol: HTTP
hosts:
- "tracing.${INGRESS_DOMAIN}"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: tracing-vs
namespace: istio-system
spec:
hosts:
- "tracing.${INGRESS_DOMAIN}"
gateways:
- tracing-gateway
http:
- route:
- destination:
host: tracing
port:
number: 80
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: tracing
namespace: istio-system
spec:
host: tracing
trafficPolicy:
tls:
mode: DISABLE
---
EOF
while [[ $(kubectl get pods -l app=kiali -n istio-system -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]
do
echo "waiting for kiali pod"
kubectl get pods -n istio-system
sleep 60
done
echo "Open http://kiali.istio-cluster.org"
echo "Open http://grafana.istio-cluster.org"
echo "Open http://tracing.istio-cluster.org"
kubectl create namespace travel-agency
kubectl create namespace travel-portal
kubectl create namespace travel-control
kubectl label namespace travel-agency istio-injection=enabled
kubectl label namespace travel-portal istio-injection=enabled
kubectl apply -f <(curl -L https://raw.githubusercontent.com/kiali/demos/master/travels/travel_agency.yaml) -n travel-agency
kubectl apply -f <(curl -L https://raw.githubusercontent.com/kiali/demos/master/travels/travel_portal.yaml) -n travel-portal
kubectl apply -f <(curl -L https://raw.githubusercontent.com/kiali/demos/master/travels/travel_control.yaml) -n travel-control
while [[ $(kubectl get pods -l app=control -n travel-control -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]
do
echo "waiting for control pod"
kubectl get pods -n travel-control
sleep 15
done
while [[ $(kubectl get pods -l app=voyages -n travel-portal -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]
do
echo "waiting for voyages pod"
kubectl get pods -n travel-portal
sleep 15
done
while [[ $(kubectl get pods -l app=mysqldb -n travel-agency -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]
do
echo "waiting for mysqldb pod"
kubectl get pods -n travel-agency
sleep 15
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment