Created
October 17, 2022 17:02
-
-
Save NimJay/8f61b95740751a86f9192d5b79f5563e to your computer and use it in GitHub Desktop.
This is the most convenient, non-Terraform way I know to create a new Google Kubernetes Engine (GKE) cluster with in-cluster Anthos Service Mesh (ASM) installed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you're not using Cloud Shell, make sure to replace $GOOGLE_CLOUD_PROJECT with your Project ID. | |
# Cloud Shell is a small virtual machine (in Google Cloud) that's tied to your Google Cloud account. | |
export PROJECT_ID=$GOOGLE_CLOUD_PROJECT | |
export CLUSTER_NAME=my-cluster-with-in-cluster-asm-1 | |
export KUBECONTEXT_NAME=${CLUSTER_NAME} | |
export ZONE=us-central1-b | |
export PROJECT_NUMBER=$(gcloud projects describe ${PROJECT_ID} --format='get(projectNumber)') | |
export ASM_VERSION=1.14 | |
echo "🏗️ Enabling necessary Google Cloud APIs..." | |
gcloud services enable \ | |
container.googleapis.com | |
echo "☁️ Creating a new Google Kubernetes Engine (GKE) cluster..." | |
gcloud container clusters create ${CLUSTER_NAME} \ | |
--project=${PROJECT_ID} \ | |
--zone=${ZONE} \ | |
--machine-type=e2-standard-4 \ | |
--num-nodes=2 \ | |
--workload-pool=${PROJECT_ID}.svc.id.goog | |
echo "✏️ Renaming kubeconfig context of the cluster to ${CLUSTER_NAME}..." | |
kubectl config rename-context \ | |
gke_${PROJECT_ID}_${ZONE}_${CLUSTER_NAME} ${CLUSTER_NAME} | |
echo "📩 Downloading asmcli, the tool used to install in-cluster Anthos Service Mesh..." | |
curl https://storage.googleapis.com/csm-artifacts/asm/asmcli_${ASM_VERSION} > asmcli | |
echo "🪄 Making asmcli executable..." | |
chmod +x asmcli | |
echo "💉 Installing in-cluster Anthos Service Mesh" | |
./asmcli install \ | |
--project_id ${PROJECT_ID} \ | |
--cluster_name ${CLUSTER_NAME} \ | |
--cluster_location ${ZONE} \ | |
--fleet_id ${PROJECT_ID} \ | |
--output_dir . \ | |
--enable_all \ | |
--ca mesh_ca | |
# ----- A D D I T I O N A L I N F O ----- | |
# A "mesh_id" label on the cluster is required for metrics to get displayed on the ASM Dashboard in the Cloud Console. | |
# You can set the "mesh_id" label on the cluster using: | |
# gcloud container clusters update ${CLUSTER_NAME} \ | |
# --zone ${ZONE} \ | |
# --update-labels mesh_id=proj-${PROJECT_NUMBER} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment