-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
106 lines (91 loc) · 2.68 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
BOX_IMAGE = "ubuntu/bionic64"
# Networking
HOST_ONLY_NETWORK = "192.168.68"
LB_IP = 5
MASTER_IP_START_AT = 10
WORKER_IP_START_AT = 20
# Spec
MASTER_NODES = 3
MASTER_CPU = 2
MASTER_RAM = 2048
WORKER_NODES = 3
WORKER_CPU = 2
WORKER_RAM = 2048
LB_CPU = 1
LB_RAM = 2048
Vagrant.configure("2") do |config|
# LB node
config.vm.define "lb01" do |l|
l.vm.provider "virtualbox" do |v|
v.name = "k8s-lb01"
v.cpus = LB_CPU
v.memory = LB_RAM
end
l.vm.box = BOX_IMAGE
l.vm.hostname = "lb01"
l.vm.network "private_network", ip: "#{HOST_ONLY_NETWORK}.#{LB_IP}"
l.vm.provision :salt do |s|
s.minion_config = "saltstack/etc/lb01"
s.minion_key = "saltstack/keys/lb01.pem"
s.minion_pub = "saltstack/keys/lb01.pub"
s.install_type = "stable"
s.colorize = true
s.verbose = true
s.bootstrap_options = "-P -c /tmp"
end
end
$disableSwap = <<-'SCRIPT'
swapoff -a
sed -i.bak '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
SCRIPT
# Master nodes
(1..MASTER_NODES).each do |i|
config.vm.define "master#{i}" do |m|
m.vm.provider "virtualbox" do |v|
v.name = "k8s-master#{i}"
v.cpus = MASTER_CPU
v.memory = MASTER_RAM
end
m.vm.box = BOX_IMAGE
m.vm.hostname = "master#{i}"
m.vm.network "private_network", ip: "#{HOST_ONLY_NETWORK}.#{MASTER_IP_START_AT + i}"
m.vm.provision "shell", inline: $disableSwap
m.vm.provision :salt do |s|
s.minion_config = "saltstack/etc/master#{i}"
s.minion_key = "saltstack/keys/master#{i}.pem"
s.minion_pub = "saltstack/keys/master#{i}.pub"
s.install_type = "stable"
s.colorize = true
s.verbose = true
s.bootstrap_options = "-P -c /tmp"
end
end
end
# Worker nodes
(1..WORKER_NODES).each do |i|
config.vm.define "worker#{i}" do |w|
w.vm.provider "virtualbox" do |v|
v.name = "k8s-worker#{i}"
v.cpus = WORKER_CPU
v.memory = WORKER_RAM
end
w.vm.box = BOX_IMAGE
w.vm.hostname = "worker#{i}"
w.vm.network "private_network", ip: "#{HOST_ONLY_NETWORK}.#{WORKER_IP_START_AT + i}"
w.vm.provision "shell", inline: $disableSwap
w.vm.provision :salt do |s|
s.minion_config = "saltstack/etc/worker#{i}"
s.minion_key = "saltstack/keys/worker#{i}.pem"
s.minion_pub = "saltstack/keys/worker#{i}.pub"
s.install_type = "stable"
s.colorize = true
s.verbose = true
s.bootstrap_options = "-P -c /tmp"
end
end
end
end