-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd.sh
More file actions
executable file
·100 lines (92 loc) · 3.73 KB
/
cmd.sh
File metadata and controls
executable file
·100 lines (92 loc) · 3.73 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
set -e
gcloud auth activate-service-account --key-file=/keyFile
echo "checking for exiting gke cluster"
clusterDescribeCmd="gcloud container clusters describe $name"
# handle opts
if [ "$zone" != " " ]; then
clusterDescribeCmd=$(printf "%s --zone %s" "$clusterDescribeCmd" "$zone")
fi
if [ "$region" != " " ]; then
clusterDescribeCmd=$(printf "%s --region %s" "$clusterDescribeCmd" "$region")
fi
if eval "$clusterDescribeCmd" >/dev/null 2>&1
then
echo "found exiting gke cluster"
exit
else
echo "existing gke cluster not found"
fi
echo "creating gke cluster..."
clusterCreateCmd="gcloud container clusters create $name"
clusterCreateCmd=$(printf "%s --disk-size %s" "$clusterCreateCmd" "$diskSize")
clusterCreateCmd=$(printf "%s --disk-type %s" "$clusterCreateCmd" "$diskType")
clusterCreateCmd=$(printf "%s --network %s" "$clusterCreateCmd" "$network")
clusterCreateCmd=$(printf "%s --num-nodes %s" "$clusterCreateCmd" "$numNodes")
clusterCreateCmd=$(printf "%s --machine-type %s" "$clusterCreateCmd" "$machineType")
clusterCreateCmd=$(printf "%s --max-nodes %s" "$clusterCreateCmd" "$maxNodes")
clusterCreateCmd=$(printf "%s --min-nodes %s" "$clusterCreateCmd" "$minNodes")
# handle opts
if [ "$async" = "true" ]; then
clusterCreateCmd=$(printf "%s --async" "$clusterCreateCmd")
fi
if [ "$clusterVersion" != " " ]; then
clusterCreateCmd=$(printf "%s --cluster-version %s" "$clusterCreateCmd" "$clusterVersion")
fi
if [ "$enableAutoscaling" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-autoscaling" "$clusterCreateCmd")
fi
if [ "$enableAutorepair" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-autorepair" "$clusterCreateCmd")
else
clusterCreateCmd=$(printf "%s --no-enable-autorepair" "$clusterCreateCmd")
fi
if [ "$enableAutoupgrade" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-autoupgrade" "$clusterCreateCmd")
fi
if [ "$enableCloudLogging" = "false" ]; then
clusterCreateCmd=$(printf "%s --no-enable-cloud-logging" "$clusterCreateCmd")
fi
if [ "$enableCloudMonitoring" = "false" ]; then
clusterCreateCmd=$(printf "%s --no-enable-cloud-monitoring" "$clusterCreateCmd")
fi
if [ "$enableIpAlias" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-ip-alias" "$clusterCreateCmd")
fi
if [ "$enableNetworkPolicy" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-network-policy" "$clusterCreateCmd")
fi
if [ "$enableKubernetesAlpha" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-kubernetes-alpha" "$clusterCreateCmd")
fi
if [ "$enableMasterAuthorizedNetworks" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-master-authorized-networks" "$clusterCreateCmd")
fi
if [ "$enablePrivateEndpoint" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-private-endpoint" "$clusterCreateCmd")
fi
if [ "$enablePrivateNodes" = "true" ]; then
clusterCreateCmd=$(printf "%s --enable-private-nodes" "$clusterCreateCmd")
fi
if [ "$masterAuthorizedNetworks" != " " ]; then
clusterCreateCmd=$(printf "%s --master-authorized-networks %s" "$clusterCreateCmd" "$masterAuthorizedNetworks")
fi
if [ "$masterIpv4Cidr" != " " ]; then
clusterCreateCmd=$(printf "%s --master-ipv4-cidr %s" "$clusterCreateCmd" "$masterIpv4Cidr")
fi
if [ "$nodeLocations" != " " ]; then
clusterCreateCmd=$(printf "%s --node-locations %s" "$clusterCreateCmd" "$nodeLocations")
fi
if [ "$preemptible" = "true" ]; then
clusterCreateCmd=$(printf "%s --preemptible" "$clusterCreateCmd")
fi
if [ "$region" != " " ]; then
clusterCreateCmd=$(printf "%s --region %s" "$clusterCreateCmd" "$region")
fi
if [ "$subnetwork" != " " ]; then
clusterCreateCmd=$(printf "%s --subnetwork %s" "$clusterCreateCmd" "$subnetwork")
fi
if [ "$zone" != " " ]; then
clusterCreateCmd=$(printf "%s --zone %s" "$clusterCreateCmd" "$zone")
fi
eval "$clusterCreateCmd"