init
This commit is contained in:
commit
9faf7b6fe7
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.vagrant
|
29
p1/Vagrantfile
vendored
Normal file
29
p1/Vagrantfile
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.synced_folder ".", "/vagrant"
|
||||||
|
config.vm.box = "debian/buster64"
|
||||||
|
|
||||||
|
config.vm.define "cchauvetS" do |server|
|
||||||
|
server.vm.hostname = "cchauvetS"
|
||||||
|
server.vm.network "private_network", ip: "192.168.56.110"
|
||||||
|
|
||||||
|
server.vm.provider "virtualbox" do |vb|
|
||||||
|
vb.memory = "2048"
|
||||||
|
vb.cpus = "2"
|
||||||
|
end
|
||||||
|
|
||||||
|
server.vm.provision "shell", path: "scripts/server.sh"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.define "cchauvetSW" do |agent|
|
||||||
|
agent.vm.hostname = "cchauvetSW"
|
||||||
|
agent.vm.network "private_network", ip: "192.168.56.111"
|
||||||
|
|
||||||
|
agent.vm.provider "virtualbox" do |vb|
|
||||||
|
vb.memory = "512"
|
||||||
|
vb.cpus = "1"
|
||||||
|
end
|
||||||
|
|
||||||
|
agent.vm.provision "shell", path: "scripts/agent.sh", args: ["192.168.56.110"]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
11
p1/scripts/agent.sh
Normal file
11
p1/scripts/agent.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
apt update
|
||||||
|
apt install -y build-essential dkms linux-headers-generic
|
||||||
|
# Get the master node's IP from the arguments
|
||||||
|
MASTER_IP=$1
|
||||||
|
|
||||||
|
# Get the token from the shared folder
|
||||||
|
TOKEN=$(cat /vagrant/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 -
|
16
p1/scripts/server.sh
Normal file
16
p1/scripts/server.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
apt update
|
||||||
|
sudo apt install -y build-essential dkms linux-headers-generic
|
||||||
|
# Install K3s on the master node
|
||||||
|
curl -sfL https://get.k3s.io | sh -
|
||||||
|
|
||||||
|
# Make sure kubectl is set up for the vagrant user
|
||||||
|
sudo mkdir -p /home/vagrant/.kube
|
||||||
|
sudo cp /etc/rancher/k3s/k3s.yaml /home/vagrant/.kube/config
|
||||||
|
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)
|
||||||
|
|
||||||
|
# Store the token for the workers to use
|
||||||
|
echo $TOKEN > /vagrant/token
|
Loading…
Reference in New Issue
Block a user