-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgke-deploy.sh
executable file
·30 lines (27 loc) · 1.24 KB
/
gke-deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
echo '-------Creating a GKE Cluster only (typically in ~5 mins)'
starttime=$(date +%s)
. ./setenv.sh
TEMP_PREFIX=$(echo $(whoami) | sed -e 's/\_//g' | sed -e 's/\.//g' | awk '{print tolower($0)}')
FIRST3=$(echo -n $TEMP_PREFIX | head -c3)
LAST3=$(echo -n $TEMP_PREFIX | tail -c3)
MY_PREFIX=$(echo $FIRST3$LAST3)
GKE_K8S_VERSION=$(gcloud container get-server-config --region us-central1 --flatten="channels" --filter="channels.channel=RAPID" | grep $K8S_VERSION | awk '{print $2}' | sort -r | uniq | head -1)
gcloud container clusters create $MY_PREFIX-$MY_CLUSTER-$(date +%s) \
--zone $MY_ZONE \
--num-nodes 1 \
--machine-type $MY_MACHINE_TYPE \
--release-channel=rapid \
--cluster-version $GKE_K8S_VERSION \
--no-enable-basic-auth \
--addons=GcePersistentDiskCsiDriver,BackupRestore \
--enable-autoscaling --min-nodes 1 --max-nodes 3
echo "" | awk '{print $1}'
./postgresql-deploy.sh
endtime=$(date +%s)
duration=$(( $endtime - $starttime ))
echo "" | awk '{print $1}'
echo "-------Total time to build a GKE cluster with PostgreSQL is $(($duration / 60)) minutes $(($duration % 60)) seconds."
echo "" | awk '{print $1}'
echo "-------Created by Yongkang"
echo "-------Email me if any suggestions or issues [email protected]"
echo "" | awk '{print $1}'