-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutils.sh
More file actions
executable file
·117 lines (104 loc) · 2.71 KB
/
Copy pathutils.sh
File metadata and controls
executable file
·117 lines (104 loc) · 2.71 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash -
#title :utils.sh
#description :utils
#==============================================================================
my_dir=$(dirname "${BASH_SOURCE}")
function warn {
echo -e "\033[1;33mWARNING: $1\033[0m"
}
function error {
echo -e "\033[0;31mERROR: $1\033[0m"
}
function inf {
echo -e "\033[0;32m$1\033[0m"
}
function show_help {
inf "Usage: \n"
inf "gce-up.sh or gce-down.sh [flags] \n"
inf "Flags are:"
inf "-a|--machine-type - GCE machine type. Default is n1-standard-1"
inf "-c|--cidr - CIDR range for LBEX instance IP addresses, big enough for at least 'num-autoscale' IPs. Should not clash with GKE cluster ip space. Default is 10.150.0.0/28."
inf "-g|--ingress-cidr - Restrict traffic incoming to lbex cluster to this CIDR"
inf "-h|--help - Show this help.\n"
inf "-i|--project - Google project id. Required."
inf "-m|--cluster-name - Target GKE cluster name. Required for gce-up.sh."
inf "-n|--name - base name for all lbex resource. Required."
inf "-p|--health-port - LBEX healthcheck port. Default is 7331."
inf "-r|--region - GCE region name. Default is us-central1."
inf "-s|--num-autoscale - Maximum number of autoscaled LBEX instances. Default is 10."
inf "-t|--cluster-network - GCE network name of the GKE cluster. Must be a custom type network. Required"
inf "-z|--cluster-zone - Target GKE cluster primary zone. Default is us-central1-a."
inf "For example:"
inf "gce-up.sh --name mylbex --project k8s-work --cidr 10.128.0.0/28 --region us-central1 --cluster-name my-k8s-cluster --num-autoscale 10 --cluster-zone us-central1-a --cluster-network my-cluster-network --health-port 1337"
inf "or"
inf "gce-down.sh --name mylbex --region us-central1 --project k8s-work"
}
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-a|--machine-type)
GCE_MACHINE_TYPE="$2"
shift
;;
-n|--name)
LBEX_BASE_NAME="$2"
shift
;;
-g|--ingress-cidr)
LBEX_INGRESS_CIDR="$2"
shift
;;
-i|--project)
LBEX_PROJECT="$2"
shift
;;
-c|--cidr)
LBEX_CIDR="$2"
shift
;;
-r|--region)
LBEX_REGION="$2"
shift
;;
-m|--cluster-name)
LBEX_CLUSTER_NAME="$2"
shift
;;
-t|--cluster-network)
LBEX_CLUSTER_NETWORK="$2"
shift
;;
-s|--num-autoscale)
LBEX_MAX_AUTOSCALE="$2"
shift
;;
-z|--cluster-zone)
LBEX_CLUSTER_ZONE="$2"
shift
;;
-p|--health-port)
LBEX_HEALTH_PORT="$2"
shift
;;
-h|--help)
LBEX_HELP=true
;;
*)
LBEX_HELP=true
;;
esac
shift # past argument or value
done
if [ -n "${LBEX_HELP+x}" ]; then
show_help
exit 0
fi
if [ -z "${LBEX_PROJECT+x}" ]; then
show_help
exit 1
fi
if [ -z "${LBEX_BASE_NAME+x}" ]; then
show_help
exit 1
fi