-
Notifications
You must be signed in to change notification settings - Fork 0
/
provisionGke.sh
executable file
·57 lines (51 loc) · 2.1 KB
/
provisionGke.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# values read in from creds file
RESOURCE_PREFIX=$(cat creds.json | jq -r '.resourcePrefix')
GKE_PROJECT=$(cat creds.json | jq -r '.gkeProject')
CLUSTER_ZONE=$(cat creds.json | jq -r '.clusterZone')
CLUSTER_NAME="$RESOURCE_PREFIX"-dt-kube-demo-cluster
<<<<<<< HEAD
NETWORK_NAME=gcp-dev-network
=======
NETWORK_NAME=gke-dev-network
SUBNET_NAME=subnet-dev-gke-uscentral1
>>>>>>> 91ae116bb4a725a70b96193bdb4f31e925d22b8e
echo "===================================================="
echo "About to provision GCP Resources. "
echo "The provisioning will take several minutes"
echo "Cluster Name : $CLUSTER_NAME"
echo "Cluster Zone : $CLUSTER_ZONE"
echo "===================================================="
read -rsp $'Press ctrl-c to abort. Press any key to continue...\n' -n1 key
echo ""
echo "------------------------------------------------------"
echo "Creating GKE Cluster: $CLUSTER_NAME"
echo "------------------------------------------------------"
# gcloud container clusters create $CLUSTER_NAME \
# --project=$GKE_PROJECT \
# --machine-type n1-standard-2 \
# --num-nodes 3 \
# --zone $CLUSTER_ZONE \
# --cluster-version latest \
# --enable-cloud-logging \
# --enable-cloud-monitoring \
# --subnetwork default
gcloud container clusters create $CLUSTER_NAME \
--project $GKE_PROJECT \
--machine-type n1-standard-2 \
--num-nodes 3 \
--zone=$CLUSTER_ZONE \
--cluster-version latest \
--network $NETWORK_NAME \
--subnetwork subnet-dev-gke-uscentral1 \
--cluster-secondary-range-name range-1 \
--services-secondary-range-name range-2 \
--enable-ip-alias
echo "------------------------------------------------------"
echo "Getting Cluster Credentials"
echo "------------------------------------------------------"
gcloud container clusters get-credentials $CLUSTER_NAME
echo "------------------------------------------------------"
echo "account permissions to perform administrative actions"
echo "------------------------------------------------------"
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account)