Skip to content

Instantly share code, notes, and snippets.

@eliihen
Last active December 9, 2021 14:50
Show Gist options
  • Save eliihen/1a03f034e87385be2417d9f66ce7f066 to your computer and use it in GitHub Desktop.
Save eliihen/1a03f034e87385be2417d9f66ce7f066 to your computer and use it in GitHub Desktop.
Install Anthos Service Mesh with hipster store demo app on GCP
#!/bin/bash
# This script installs Anthos Service Mesh with the hipster store demo app on GCP
# Exit on failing command
set -e
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
export CLUSTER_NAME=anthos-cluster
export CLUSTER_LOCATION=us-central1-c
export CLUSTER_VERSION="1.21.5-gke.1302"
export CLUSTER_RELEASE_CHANNEL=regular
export CLUSTER_MACHINE_TYPE=e2-standard-4
export DIR_PATH=asm_install
export INGRESS_NAMESPACE=istio-ingress
gcloud beta container clusters create $CLUSTER_NAME \
--zone $CLUSTER_LOCATION \
--no-enable-basic-auth \
--cluster-version $CLUSTER_VERSION \
--release-channel $CLUSTER_RELEASE_CHANNEL \
--machine-type $CLUSTER_MACHINE_TYPE \
--node-locations $CLUSTER_LOCATION
curl https://storage.googleapis.com/csm-artifacts/asm/asmcli_1.11 > asmcli
chmod +x asmcli
./asmcli validate \
--project_id $PROJECT_ID \
--cluster_name $CLUSTER_NAME \
--cluster_location $CLUSTER_LOCATION \
--output_dir $DIR_PATH
./asmcli install \
--project_id $PROJECT_ID \
--cluster_name $CLUSTER_NAME \
--cluster_location $CLUSTER_LOCATION \
--enable_all \
--output-dir $DIR_PATH \
--ca mesh_ca
# Locate the label on istiod
export ISTIO_REV=$(kubectl get deploy -n istio-system -l app=istiod -o \
jsonpath={.items[*].metadata.labels.'istio\.io\/rev'}'{"\n"}')
kubectl create namespace $INGRESS_NAMESPACE
kubectl label namespace $INGRESS_NAMESPACE istio.io/rev=$ISTIO_REV --overwrite
kubectl apply -n $INGRESS_NAMESPACE \
-f $DIR_PATH/samples/gateways/istio-ingressgateway
kpt pkg get \
https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages.git/samples/online-boutique \
online-boutique
kubectl apply -f online-boutique/kubernetes-manifests/namespaces
kubectl apply -f online-boutique/kubernetes-manifests/deployments
kubectl apply -f online-boutique/kubernetes-manifests/services
kubectl apply -f online-boutique/istio-manifests/allow-egress-googleapis.yaml
# Apply revision label to all namespaces
for ns in ad cart checkout currency email frontend loadgenerator \
payment product-catalog recommendation shipping; do
kubectl label namespace $ns istio.io/rev=$ISTIO_REV --overwrite
done;
# Restart the pods
for ns in ad cart checkout currency email frontend loadgenerator \
payment product-catalog recommendation shipping; do
kubectl rollout restart deployment -n ${ns}
done;
# Deploy a Gateway and VirtualService for the frontend service
kubectl apply -f online-boutique/istio-manifests/frontend-gateway.yaml
# Get the external IP address of the ingress gateway
export GATEWAY_IP=$(kubectl get service istio-ingressgateway -n $INGRESS_NAMESPACE -o \
jsonpath={.status.loadBalancer.ingress[0].ip})
echo "Application is accessible at http://$GATEWAY_IP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment