fix: wait token created befort start k3s

This commit is contained in:
starnakin 2025-02-22 12:20:17 -05:00
parent 1cfa5df370
commit 2e2b779fdd
2 changed files with 7 additions and 0 deletions

View File

@ -3,7 +3,13 @@
MASTER_IP=$1 MASTER_IP=$1
# Get the token from the shared folder # Get the token from the shared folder
while [ ! -f /vagrant/token ]
do
sleep 2 # or less like 0.2
done
TOKEN=$(cat /vagrant/token) TOKEN=$(cat /vagrant/token)
echo "token: $TOKEN"
# Install K3s agent (worker) and join the master node # 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 - curl -sfL https://get.k3s.io | K3S_URL=https://$MASTER_IP:6443 K3S_TOKEN=$TOKEN sh -
rm -f /vagrant/token

View File

@ -9,6 +9,7 @@ sudo chown -R vagrant:vagrant /home/vagrant/.kube/config
# Get the token for the worker nodes # Get the token for the worker nodes
TOKEN=$(sudo cat /var/lib/rancher/k3s/server/node-token) TOKEN=$(sudo cat /var/lib/rancher/k3s/server/node-token)
echo "token: $TOKEN"
# Store the token for the workers to use # Store the token for the workers to use
echo $TOKEN > /vagrant/token echo $TOKEN > /vagrant/token