-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
55 lines (50 loc) · 1.96 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
##
# Mostly stolen from https://kubernetes.io/blog/2019/03/15/kubernetes-setup-using-ansible-and-vagrant/
##
## See https://github.com/chef/bento/issues/1185#issuecomment-611479227 for failing mount fix then run vagrant reload
IMAGE_NAME = "bento/ubuntu-20.04"
BOX_VERSION = "202107.07.0"
K8S_VERSION = "1.22.4"
N = 3
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
config.vagrant.plugins = ["vagrant-disksize", "vagrant-vbguest"]
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 4
end
config.vm.define "k8s-master-#{K8S_VERSION}" do |master|
master.vm.box = IMAGE_NAME
master.vm.box_version = BOX_VERSION
master.vm.network "public_network", ip: "192.168.1.200", bridge: "Realtek PCIe 2.5GbE Family Controller"
master.vm.hostname = "k8s-master-#{K8S_VERSION}"
master.vm.provision "ansible_local" do |ansible|
ansible.playbook = "kubernetes-setup/master-playbook.yml"
ansible.verbose = true
ansible.extra_vars = {
node_ip: "192.168.1.200",
node_hostname: "k8s-master"
}
end
end
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 4
end
(1..N).each do |i|
config.vm.define "k8s-node-#{K8S_VERSION}-#{i}" do |node|
node.vm.box = IMAGE_NAME
node.vm.box_version = BOX_VERSION
node.vm.network "public_network", ip: "192.168.1.#{i + 200}", bridge: "Realtek PCIe 2.5GbE Family Controller"
node.vm.hostname = "node-#{K8S_VERSION}-#{i}"
node.vm.provision "ansible_local" do |ansible|
ansible.playbook = "kubernetes-setup/node-playbook.yml"
ansible.verbose = true
ansible.extra_vars = {
node_ip: "192.168.1.#{i + 200}",
node_hostname: "node-#{K8S_VERSION}-#{i}"
}
end
end
end
end