@@ -136,6 +136,9 @@ function setup_master() {
136
136
/^ApiserverToken:/ {token=$2} \
137
137
/^ApiserverDiscoveryToken:/ {token_hash=$2} \
138
138
END {print "sudo kubeadm join " ip ":" port " --token " token " --discovery-token-ca-cert-hash " token_hash}' \' ' ~/vhive/scripts/masterKey.yaml' )
139
+
140
+ server_exec $MASTER_NODE " kubectl taint nodes \$ (hostname) node-role.kubernetes.io/control-plane-"
141
+ server_exec $MASTER_NODE " kubectl label nodes \$ (hostname) loader-nodetype=master"
139
142
}
140
143
141
144
function setup_vhive_firecracker_daemon() {
@@ -164,9 +167,19 @@ function setup_workers() {
164
167
165
168
if [ " $2 " = " MASTER" ]; then
166
169
server_exec $node " sudo ${MASTER_LOGIN_TOKEN} "
170
+ server_exec $node " kubectl taint nodes \$ (hostname) node-role.kubernetes.io/control-plane-"
171
+ server_exec $node " kubectl label nodes \$ (hostname) loader-nodetype=master"
167
172
echo " Backup master node $node has joined the cluster."
168
173
else
169
174
server_exec $node " sudo ${LOGIN_TOKEN} "
175
+
176
+ if [ " $3 " = " LOADER" ]; then
177
+ # First node after the control plane nodes
178
+ server_exec $node " kubectl label nodes \$ (hostname) loader-nodetype=monitoring" < /dev/null
179
+ else
180
+ server_exec $node " kubectl label nodes \$ (hostname) loader-nodetype=worker" < /dev/null
181
+ fi
182
+
170
183
echo " Worker node $node has joined the cluster."
171
184
fi
172
185
@@ -177,28 +190,22 @@ function setup_workers() {
177
190
server_exec $node " echo \" containerLogMaxSize: 512Mi\" > >(sudo tee -a /var/lib/kubelet/config.yaml >/dev/null)"
178
191
server_exec $node ' sudo systemctl daemon-reload && sudo systemctl restart kubelet'
179
192
server_exec $node ' sleep 10'
180
-
181
- # Rejoin has to be performed although errors will be thrown. Otherwise, restarting the kubelet will cause the node unreachable for some reason
182
-
183
- if [ " $2 " = " MASTER" ]; then
184
- server_exec $node " sudo ${MASTER_LOGIN_TOKEN} > /dev/null 2>&1"
185
- echo " Backup master node $node joined the cluster (again :P)."
186
- else
187
- server_exec $node " sudo ${LOGIN_TOKEN} > /dev/null 2>&1"
188
- echo " Worker node $node joined the cluster (again :P)."
189
- fi
190
193
}
191
194
192
195
NODE_COUNTER=1
193
196
for node in " $@ "
194
197
do
195
198
# Set up API Server load balancer arguments - Less than because 1 CP is the "main" master node already
196
- HA_SETTING=" "
199
+ HA_SETTING=" OTHER"
200
+ LOADER_NODE=" OTHER"
201
+
197
202
if [ " $NODE_COUNTER " -lt $CONTROL_PLANE_REPLICAS ]; then
198
203
HA_SETTING=" MASTER"
204
+ elif [ " $NODE_COUNTER " -eq $CONTROL_PLANE_REPLICAS ]; then
205
+ LOADER_NODE=" LOADER"
199
206
fi
200
207
201
- internal_setup " $node " $HA_SETTING &
208
+ internal_setup " $node " " $HA_SETTING " " $LOADER_NODE " &
202
209
let NODE_COUNTER++
203
210
done
204
211
@@ -273,15 +280,17 @@ function copy_k8s_certificates() {
273
280
shift # make argument list only contain worker nodes (drops master node)
274
281
275
282
setup_master
283
+
284
+ # Copy API server certificates from master to each worker node
285
+ copy_k8s_certificates " $@ "
286
+
287
+ # Join cluster
276
288
setup_workers " $@ "
277
289
278
290
if [ $PODS_PER_NODE -gt 240 ]; then
279
291
extend_CIDR " $@ "
280
292
fi
281
293
282
- # Untaint master to schedule knative control plane there
283
- server_exec $MASTER_NODE " kubectl taint nodes \$ (hostname) node-role.kubernetes.io/control-plane-"
284
-
285
294
# Notify the master that all nodes have joined the cluster
286
295
server_exec $MASTER_NODE ' tmux send -t master "y" ENTER'
287
296
@@ -291,18 +300,8 @@ function copy_k8s_certificates() {
291
300
namespace_info=$( server_exec $MASTER_NODE " kubectl get namespaces" )
292
301
done
293
302
294
- echo " Master node $MASTER_NODE finalized."
295
-
296
- # Copy API server certificates from master to each worker node
297
- copy_k8s_certificates " $@ "
298
-
299
303
server_exec $MASTER_NODE ' cd loader; bash scripts/setup/patch_init_scale.sh'
300
304
301
- source $DIR /label.sh
302
-
303
- # Force placement of metrics collectors and instrumentation on the loader node and control plane on master
304
- label_nodes $MASTER_NODE $1 # loader node is second on the list, becoming first after arg shift
305
-
306
305
# patch knative to accept nodeselector
307
306
server_exec $MASTER_NODE " cd loader; kubectl patch configmap config-features -n knative-serving -p '{\" data\" : {\" kubernetes.podspec-nodeselector\" : \" enabled\" }}'"
308
307
0 commit comments