From 2e2b779fdd3039236095a6b01bea6e2c75abe54e Mon Sep 17 00:00:00 2001 From: starnakin Date: Sat, 22 Feb 2025 12:20:17 -0500 Subject: [PATCH] fix: wait token created befort start k3s --- p1/scripts/agent.sh | 6 ++++++ p1/scripts/server.sh | 1 + 2 files changed, 7 insertions(+) diff --git a/p1/scripts/agent.sh b/p1/scripts/agent.sh index ff8f804..a7c0d9f 100644 --- a/p1/scripts/agent.sh +++ b/p1/scripts/agent.sh @@ -3,7 +3,13 @@ MASTER_IP=$1 # Get the token from the shared folder +while [ ! -f /vagrant/token ] +do + sleep 2 # or less like 0.2 +done TOKEN=$(cat /vagrant/token) +echo "token: $TOKEN" # Install K3s agent (worker) and join the master node curl -sfL https://get.k3s.io | K3S_URL=https://$MASTER_IP:6443 K3S_TOKEN=$TOKEN sh - +rm -f /vagrant/token diff --git a/p1/scripts/server.sh b/p1/scripts/server.sh index ce02205..2440a3e 100644 --- a/p1/scripts/server.sh +++ b/p1/scripts/server.sh @@ -9,6 +9,7 @@ sudo chown -R vagrant:vagrant /home/vagrant/.kube/config # Get the token for the worker nodes TOKEN=$(sudo cat /var/lib/rancher/k3s/server/node-token) +echo "token: $TOKEN" # Store the token for the workers to use echo $TOKEN > /vagrant/token