-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
58 lines (51 loc) · 1.67 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- mode: ruby -*-
# vi: set ft=ruby :
master_ip = "192.168.56.10"
agent_ip = "192.168.56.11"
# Extra parameters in INSTALL_K3S_EXEC variable because of
# K3s picking up the wrong interface when starting server and agent
# https://github.com/alexellis/k3sup/issues/306
master_script = <<-SHELL
sudo -i
apk add curl
export INSTALL_K3S_EXEC="--bind-address=#{master_ip} \
--node-external-ip=#{master_ip} \
--flannel-iface=eth1"
curl -sfL https://get.k3s.io | sh -
sleep 5
cp /var/lib/rancher/k3s/server/token /vagrant_shared
chmod 644 /etc/rancher/k3s/k3s.yaml
cp /etc/rancher/k3s/k3s.yaml /vagrant_shared
cp /etc/rancher/k3s/k3s.yaml /
SHELL
agent_script = <<-SHELL
sudo -i
apk add curl
export K3S_TOKEN_FILE=/vagrant_shared/token
export K3S_URL=https://#{master_ip}:6443
export INSTALL_K3S_EXEC="--flannel-iface=eth1"
curl -sfL https://get.k3s.io | sh -
SHELL
Vagrant.configure("2") do |config|
config.vm.box = "generic/alpine314"
config.vm.define "master", primary: true do |master|
master.vm.network "private_network", ip: master_ip
master.vm.synced_folder "./k3s", "/vagrant_shared"
master.vm.hostname = "master"
master.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = "2"
end
master.vm.provision "shell", inline: master_script
end
config.vm.define "agent" do |agent|
agent.vm.network "private_network", ip: agent_ip
agent.vm.synced_folder "./k3s", "/vagrant_shared"
agent.vm.hostname = "agent"
agent.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.cpus = "1"
end
agent.vm.provision "shell", inline: agent_script
end
end