mirror of
https://codeberg.org/27/inception-of-things.git
synced 2025-12-31 13:46:53 +01:00
「✨」 feat: fixed the p1 so it launch in one command, no more --no-provision
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
.direnv/
|
||||
.vagrant/
|
||||
*.log
|
||||
iot-box.qcow2
|
||||
|
||||
.env
|
||||
|
||||
23
p1/Vagrantfile
vendored
23
p1/Vagrantfile
vendored
@ -23,27 +23,26 @@ end
|
||||
# • Be able to connect with SSH on both machines with no password.
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = []
|
||||
config.vm.box = "generic/alpine319"
|
||||
|
||||
config.vm.box = "debian/bookworm64"
|
||||
config.vm.provider "#{IOT_PROVIDER}" do |provider|
|
||||
provider.cpus = 1
|
||||
provider.memory = 1024
|
||||
provider.cpus = 2
|
||||
provider.memory = 2048
|
||||
end
|
||||
|
||||
config.vm.define "#{IOT_LOGIN}S" do |server|
|
||||
server.vm.hostname = "#{IOT_LOGIN}S"
|
||||
server.vm.network "private_network", ip: "192.168.56.110", auto_config: true
|
||||
server.vm.network "private_network", ip: "192.168.56.110"
|
||||
server.vm.synced_folder ".", "/vagrant"
|
||||
|
||||
server.vm.provision "shell", path: "scripts/install-all.sh"
|
||||
server.vm.provision "shell", path: "scripts/setup-S.sh"
|
||||
server.vm.provision "shell", privileged: true, path: "scripts/setup-S.sh"
|
||||
end
|
||||
|
||||
config.vm.define "#{IOT_LOGIN}SW" do |serverworker|
|
||||
serverworker.vm.hostname = "#{IOT_LOGIN}SW"
|
||||
serverworker.vm.network "private_network", ip: "192.168.56.111", auto_config: true
|
||||
config.vm.define "#{IOT_LOGIN}SW" do |worker|
|
||||
worker.vm.hostname = "#{IOT_LOGIN}SW"
|
||||
worker.vm.network "private_network", ip: "192.168.56.111"
|
||||
worker.vm.synced_folder ".", "/vagrant"
|
||||
|
||||
serverworker.vm.provision "shell", path: "scripts/install-all.sh"
|
||||
serverworker.vm.provision "shell", path: "scripts/setup-SW.sh"
|
||||
worker.vm.provision "shell", privileged: true, path: "scripts/setup-SW.sh"
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
sudo apt update
|
||||
sudo apt install curl -y
|
||||
@ -1,6 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
S_ADDR="192.168.56.110"
|
||||
|
||||
echo "Launching k3s install"
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--write-kubeconfig-mode 644" sh -s - server --cluster-init --node-ip=192.168.56.110
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--write-kubeconfig-mode 644" sh -s - server --cluster-init --node-ip=$S_ADDR --bind-address=$S_ADDR --advertise-address=$S_ADDR
|
||||
|
||||
# Additional wait to ensure API is responsive (optional but helpful)
|
||||
echo Waiting
|
||||
sleep 15
|
||||
|
||||
echo "Copying token"
|
||||
sudo cat /var/lib/rancher/k3s/server/node-token > /vagrant/node-token
|
||||
cat /var/lib/rancher/k3s/server/node-token > /vagrant/node-token
|
||||
|
||||
@ -1,8 +1,32 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
while [ ! -f /vagrant/node-token ];
|
||||
do sleep 2;
|
||||
done
|
||||
S_ADDR="192.168.56.110"
|
||||
SW_ADDR="192.168.56.111"
|
||||
|
||||
TOKEN=$(cat /vagrant/node-token)
|
||||
curl -sfL https://get.k3s.io | K3S_URL=https://192.168.56.110:6443 K3S_TOKEN=$TOKEN sh -s - --node-ip=192.168.56.111
|
||||
# In setup-SW.sh, before the k3s install command
|
||||
# echo "Checking connectivity to server"
|
||||
# I=0
|
||||
# while ! curl -k https://$S_ADDR:6443/healthz > /dev/null 2>&1; do
|
||||
# echo "Server API not reachable yet, waiting..."
|
||||
# sleep 5
|
||||
# I=$((I+1))
|
||||
# if [ $I -eq 5 ]; then
|
||||
# exit 1
|
||||
# fi
|
||||
# done
|
||||
echo "Server is reachable, proceeding with k3s agent install"
|
||||
|
||||
echo "Waiting for token"
|
||||
I=0
|
||||
while [ ! -f /vagrant/node-token ]; do
|
||||
sleep 2;
|
||||
I=$((I+1))
|
||||
if [ $I -eq 20 ]; then
|
||||
echo "threshold gone, ffs"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "Token found"
|
||||
|
||||
echo "Launching k3s install"
|
||||
curl -sfL https://get.k3s.io | K3S_URL=https://$S_ADDR:6443 sh -s - agent --node-ip=$SW_ADDR --token-file /vagrant/node-token --server https://$S_ADDR:6443
|
||||
|
||||
13
vm/Vagrantfile
vendored
Normal file
13
vm/Vagrantfile
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "generic/debian12"
|
||||
config.vm.box_version = "4.3.12"
|
||||
config.vm.network "public_network"
|
||||
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
apt-get update -y
|
||||
apt-get install -y git curl
|
||||
SHELL
|
||||
end
|
||||
Reference in New Issue
Block a user