Skip to content

Commit 61b5e72

Browse files
committed
Fixed issues with node labelling
Signed-off-by: Lazar Cvetković <l.cvetkovic.997@gmail.com>
1 parent 16fcd40 commit 61b5e72

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

scripts/setup/create_multinode.sh

+24-25
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ function setup_master() {
136136
/^ApiserverToken:/ {token=$2} \
137137
/^ApiserverDiscoveryToken:/ {token_hash=$2} \
138138
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"
139142
}
140143

141144
function setup_vhive_firecracker_daemon() {
@@ -164,9 +167,19 @@ function setup_workers() {
164167

165168
if [ "$2" = "MASTER" ]; then
166169
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"
167172
echo "Backup master node $node has joined the cluster."
168173
else
169174
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+
170183
echo "Worker node $node has joined the cluster."
171184
fi
172185

@@ -177,28 +190,22 @@ function setup_workers() {
177190
server_exec $node "echo \"containerLogMaxSize: 512Mi\" > >(sudo tee -a /var/lib/kubelet/config.yaml >/dev/null)"
178191
server_exec $node 'sudo systemctl daemon-reload && sudo systemctl restart kubelet'
179192
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
190193
}
191194

192195
NODE_COUNTER=1
193196
for node in "$@"
194197
do
195198
# 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+
197202
if [ "$NODE_COUNTER" -lt $CONTROL_PLANE_REPLICAS ]; then
198203
HA_SETTING="MASTER"
204+
elif [ "$NODE_COUNTER" -eq $CONTROL_PLANE_REPLICAS ]; then
205+
LOADER_NODE="LOADER"
199206
fi
200207

201-
internal_setup "$node" $HA_SETTING &
208+
internal_setup "$node" "$HA_SETTING" "$LOADER_NODE" &
202209
let NODE_COUNTER++
203210
done
204211

@@ -273,15 +280,17 @@ function copy_k8s_certificates() {
273280
shift # make argument list only contain worker nodes (drops master node)
274281

275282
setup_master
283+
284+
# Copy API server certificates from master to each worker node
285+
copy_k8s_certificates "$@"
286+
287+
# Join cluster
276288
setup_workers "$@"
277289

278290
if [ $PODS_PER_NODE -gt 240 ]; then
279291
extend_CIDR "$@"
280292
fi
281293

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-
285294
# Notify the master that all nodes have joined the cluster
286295
server_exec $MASTER_NODE 'tmux send -t master "y" ENTER'
287296

@@ -291,18 +300,8 @@ function copy_k8s_certificates() {
291300
namespace_info=$(server_exec $MASTER_NODE "kubectl get namespaces")
292301
done
293302

294-
echo "Master node $MASTER_NODE finalized."
295-
296-
# Copy API server certificates from master to each worker node
297-
copy_k8s_certificates "$@"
298-
299303
server_exec $MASTER_NODE 'cd loader; bash scripts/setup/patch_init_scale.sh'
300304

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-
306305
# patch knative to accept nodeselector
307306
server_exec $MASTER_NODE "cd loader; kubectl patch configmap config-features -n knative-serving -p '{\"data\": {\"kubernetes.podspec-nodeselector\": \"enabled\"}}'"
308307

0 commit comments

Comments
 (0)