-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.sh
More file actions
217 lines (187 loc) · 6.74 KB
/
environment.sh
File metadata and controls
217 lines (187 loc) · 6.74 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
############################################################################################################################
## Variables ##
############################################################################################################################
### --- Whiptail Color ---
export NEWT_COLORS='
root=,gray
'
# --- ANSI Colors ---
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# --- Global Variables ---
### Functional Variables
CHOICE=""
CHOICE_JOIN=""
CONF_CHOICE=""
declare -A worker_ips
declare -A master_ips
count_workers=0
count_masters=0
ip_master=""
username=""
passwd=""
choose_cidr=false
ip_min=""
ip_max=""
lb_cidr=""
show_range=""
lb_ip=""
network_interface=""
ip_to_join=""
### Tools
cri=""
OUTPUT_FILE="hosts"
OUTPUT_LOGS="/var/log/kvoke/kvoke.logs"
############################################################################################################################
## Texts ##
############################################################################################################################
# shellcheck disable=SC2046
WELCOME_MESSAGE=$(cat <<'EOF'
This script will guide you through the initial setup and preliminary configuration of a Kubernetes cluster.
This IaC script suite automates Kubernetes cluster installation and configuration.
It includes three official node-joining configurations, adaptable to your available infrastructure.
VMs REQUIREMENTS:
- Each VM requires a unique IP address.
- All VMs must reside on the same network (and must be reachable for each other).
- At least 2vCPU, 2GB of RAM and 25GB of storage for each Worker Node and 4vCPU, 4GB of RAM and 50GB of storage for each Master Node.
- All the VMs got to have the same sudoer user (With the same username and password).
EOF
)
WELCOME_JOIN_1=$(cat <<'EOF'
This script prepares and joins a worker node to a Kvoke cluster.
It automates the entire process, including the installation of necessary tools,
the configuration of the container runtime, and the final joining of the node to the cluster.
VM REQUIREMENTS:
- The VM requires a unique IP address.
- All VMs must reside on the same network (and must be reachable for each other), including the node to Join.
- The node needs at least 2vCPU, 2GB of RAM and 25GB of storage.
- All the VMs got to have the same sudoer user (With the same username and password), including the node to Join.
EOF
)
WELCOME_JOIN_2=$(cat <<'EOF'
This script prepares and joins a master node to a Kvoke cluster.
It automates the entire process, including the installation of necessary tools,
the configuration of the container runtime, and the final joining of the node to the cluster.
CLUSTER REQUIREMENTS:
- The cluster has to be a Kvoke Cluster already initialied as a Stacked ETCD (HA).
VM REQUIREMENTS:
- The VM requires a unique IP address.
- All VMs must reside on the same network (and must be reachable for each other), including the node to Join.
- The node needs at least 4vCPU, 4GB of RAM and 50GB of storage.
- All the VMs got to have the same sudoer user (With the same username and password), including the node to Join.
EOF
)
WELCOME_1=$(cat <<'EOF'
This cluster configuration requires less infrastructure then any other type of configuration, but it's less focused on high availability (NON-HA).
It is composed of only ONE Master node, and up to 10 Working nodes.
It's an optimal choice for simple clusters that can be used for testing environments or simple projects.
MINIMUM REQUIREMENTS:
- 1 Master Node
- 1, up to 10 Worker Nodes
VMs REQUIREMENTS:
- Each VM requires a unique IP address.
- All VMs must reside on the same network (and must be reachable for each other).
- At least 2vCPU, 2GB of RAM and 25GB of storage for each Worker Node and 4vCPU, 4GB of RAM and 50GB of storage for each Master Node.
- All the VMs got to have the same sudoer user (With the same username and password).
EOF
)
WELCOME_2=$(cat <<'EOF'
This configuration demands a more detailed infrastructure but provides optimal High Availability (HA).
It embeds the etcd components directly within each master node, leveraging a quorum algorithm to ensure the cluster
remains fully operational as long as a majority of these nodes are active.
MINIMUM REQUIREMENTS:
- 3 Master Nodes, up to 7
- Up to 10 Worker Nodes
- 1 free IP as a VIP
VMs REQUIREMENTS:
- Each VM requires a unique IP address.
- All VMs must reside on the same network (and must be reachable for each other).
- At least 2vCPU, 2GB of RAM and 25GB of storage for each Worker Node and 4vCPU, 4GB of RAM and 50GB of storage for each Master Node.
- All the VMs got to have the same sudoer user (With the same username and password).
EOF
)
USERNAME_MSG=$(cat <<'EOF'
Type the Username for the SSH connection with the VMs.
Remember that the User has to be a sudoer, and have the same credentials for each VM.
EOF
)
PASSWORD_MSG=$(cat <<'EOF'
Type the Password for the SSH connection with the VMs.
Remember that the User has to be a sudoer, and have the same credentials for each VM.
EOF
)
function confirm_page {
case $CONF_CHOICE in
1)
CONFIRM=$(cat <<EOF
Adopted configuration: Simple Configuration (NON-HA)\n
Number of Working Nodes: $count_workers\n
IP Master: $ip_master
$dialog_text
IP Address Pool for Load Balancers: $show_range\n
Container Runtime used: $cri\n
Credentials SSH sudoer\n
Username: $username
Password: $passwd
EOF
)
;;
2)
CONFIRM=$(cat <<EOF
Adopted configuration: Stacked Configuration (HA)\n
Number of Master Nodes: $count_masters\n
Number of Working Nodes: $count_workers\n
$text_masters
$text_workers
VIP KeepAliveD: $lb_ip\n
IP Address Pool for Load Balancers: $show_range\n
Container Runtime used: $cri\n
Credentials SSH sudoer\n
Username: $username
Password: $passwd
EOF
)
;;
*)
clear
echo -e "\nInvalid Option!\n"
;;
esac
}
function confirm_page_join {
case $CHOICE_JOIN in
1)
CONFIRM=$(cat <<EOF
Type of Node that is joining: Worker\n
IP Master Node: $ip_master\n
IP Node to Join: $ip_to_join\n
Container Runtime used: $cri\n
Credentials SSH sudoer\n
Username: $username
Password: $passwd
EOF
)
;;
2)
CONFIRM=$(cat <<EOF
Type of Node that is joining: Master\n
VIP of the Cluster: $vip_ip\n
IP of a random Master: $ip_master\n
IP Node to Join: $ip_to_join\n
Container Runtime used: $cri\n
Credentials SSH sudoer\n
Username: $username
Password: $passwd
EOF
)
;;
*)
clear
echo -e "\nInvalid Option!\n"
;;
esac
}