Last active
December 29, 2023 13:23
-
-
Save hgautam/aca87f3d5662859eb96fa214e9196a45 to your computer and use it in GitHub Desktop.
Script to create a Kubernets cluster in GKE
This file contains hidden or 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
#!/bin/bash | |
###################### | |
# Create The Cluster # | |
###################### | |
# helm 3 is being used for deploying Helm based Jenkins package | |
gcloud auth login | |
CLUSTER_NAME=jenkins | |
ZONE=us-west1-a | |
MACHINE_TYPE=n1-highcpu-2 | |
gcloud container clusters \ | |
create $CLUSTER_NAME \ | |
--zone $ZONE \ | |
--machine-type $MACHINE_TYPE \ | |
--enable-autoscaling \ | |
--num-nodes 1 \ | |
--max-nodes 1 \ | |
--min-nodes 1 | |
kubectl create clusterrolebinding \ | |
cluster-admin-binding \ | |
--clusterrole cluster-admin \ | |
--user $(gcloud config get-value account) | |
#Latest version of nginx controller | |
kubectl apply \ | |
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.34.1/deploy/static/provider/cloud/deploy.yaml | |
# Wait to make sure that LB IP is ready | |
echo "Retrieving LB IP....." | |
for i in $(seq 1 60); do | |
echo -ne "." | |
sleep 1 | |
done | |
echo | |
# Retrieve ingress ip | |
LB_IP=$(kubectl -n ingress-nginx\ | |
get svc ingress-nginx-controller \ | |
-o jsonpath="{.status.loadBalancer.ingress[0].ip}"); echo $LB_IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment