-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVagrantfile
35 lines (33 loc) · 1.35 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
IP_SERVER = "192.168.99.20"
IP_WORKER = "192.168.99.3"
VM_NETWORK = "vboxnet2"
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider "virtualbox" do |vb|
vb.linked_clone = true
vb.cpus = 1
vb.memory = "2048"
end
config.vm.provision "file", source: "./k3s", destination: "~/k3s"
config.vm.provision "file", source: "./token", destination: "~/token"
config.vm.define "server" do |node|
node.vm.hostname = "server"
node.vm.network "private_network", ip: IP_SERVER, virtualbox__hostnet: VM_NETWORK, adapter: 2
node.vm.provision "file", source: "./k3s-server.service", destination: "~/k3s-server.service"
node.vm.provision "shell" do |s|
s.env = {NODE_IP:IP_SERVER,NODE_EXTERNAL_IP:IP_SERVER,NODE_NAME:"server"}
s.path = "./k3s-server-init.sh"
end
end
(1..3).each do |i|
config.vm.define "worker#{i}" do |node|
node.vm.hostname = "worker#{i}"
node.vm.network "private_network", ip: "#{IP_WORKER}#{i}", virtualbox__hostnet: VM_NETWORK, adapter: 2
node.vm.provision "file", source: "./k3s-agent.service", destination: "~/k3s-agent.service"
node.vm.provision "shell" do |s|
s.env = {NODE_IP:"#{IP_WORKER}#{i}",NODE_EXTERNAL_IP:"#{IP_WORKER}#{i}",NODE_NAME:"worker#{i}",SERVER_IP:IP_SERVER}
s.path = "./k3s-agent-init.sh"
end
end
end
end