From 7fd141044e2ffd47211cb0627b0462fc433bc080 Mon Sep 17 00:00:00 2001 From: Martin Montes Date: Sat, 31 Aug 2024 20:44:27 +0200 Subject: [PATCH] Updated node join script --- README.md | 12 ++---------- label-nodes.sh | 13 ------------- worker.sh => node.sh | 15 +++++++++------ 3 files changed, 11 insertions(+), 29 deletions(-) delete mode 100755 label-nodes.sh rename worker.sh => node.sh (60%) diff --git a/README.md b/README.md index a02b9bb..cf75d25 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Setup the control-plane by running: sudo bash control-plane.sh ``` -Copy the generated configuration `config/kubeadm-join.yaml` to each worker node and run this command to join the cluster: +Copy the generated configuration files `config/kubeadm-join..yaml` to each node and run this command to join the cluster: ```bash -sudo bash worker.sh +sudo bash node.sh 'config/kubeadm-join..yaml' ``` Run this on the control-plane for bootstrapping the [infrastructure](https://github.com/mmontes11/k8s-infrastructure): @@ -43,14 +43,6 @@ export GITHUB_TOKEN= ./bootstrap.sh ``` -### Label nodes - -In order to label nodes, run the following script in the control-plane: - -```bash -./label-nodes.sh -``` - ### Kubeconfig `admin` and `super-admin` kubeconfigs are available in the following control-plane paths: diff --git a/label-nodes.sh b/label-nodes.sh deleted file mode 100755 index 37e7656..0000000 --- a/label-nodes.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -compute_nodes=( - "worker2" - "worker3" - "worker4" -) - -for node in "${compute_nodes[@]}"; do - kubectl label node "$node" "node.mmontes.io/type=compute" -done diff --git a/worker.sh b/node.sh similarity index 60% rename from worker.sh rename to node.sh index 7954960..d61db8d 100755 --- a/worker.sh +++ b/node.sh @@ -4,14 +4,18 @@ set -euo pipefail source ./scripts/lib.sh -JOIN_CONFIG_FILE=config/kubeadm-join.yaml +if [ $# -lt 1 ]; then + echo "Usage: $0 " + exit 1 +fi +JOIN_CONFIG_FILE="$1" if [ ! -f $JOIN_CONFIG_FILE ]; then echo "Join configuration file '$JOIN_CONFIG_FILE' not found" exit 1 fi -install_scripts=( +INSTALL_SCRIPTS=( "scripts/apt.sh" "scripts/swap.sh" "scripts/network.sh" @@ -19,11 +23,10 @@ install_scripts=( "scripts/containerd.sh" "scripts/kubernetes.sh" ) - -for i in "${!install_scripts[@]}"; do - source "${install_scripts[$i]}" +for INSTALL in "${INSTALL_SCRIPTS[@]}"; do + source "$INSTALL" done kubeadm join --config $JOIN_CONFIG_FILE -echo "worker installation completed successfully! 🚜" \ No newline at end of file +echo "node installation completed successfully! 🚜" \ No newline at end of file