-
Notifications
You must be signed in to change notification settings - Fork 93
/
Vagrantfile
64 lines (58 loc) · 2.24 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
IMAGE_NAME = "bento/ubuntu-20.04"
K8S_NAME = "ditwl-k8s-01"
MASTERS_NUM = 1
MASTERS_CPU = 2
MASTERS_MEM = 2048
NODES_NUM = 2
NODES_CPU = 2
NODES_MEM = 2048
IP_BASE = "192.168.50."
VAGRANT_DISABLE_VBOXSYMLINKCREATE=1
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
(1..MASTERS_NUM).each do |i|
config.vm.define "k8s-m-#{i}" do |master|
master.vm.box = IMAGE_NAME
master.vm.network "private_network", ip: "#{IP_BASE}#{i + 10}"
master.vm.hostname = "k8s-m-#{i}"
master.vm.provider "virtualbox" do |v|
v.memory = MASTERS_MEM
v.cpus = MASTERS_CPU
end
master.vm.provision "ansible" do |ansible|
ansible.playbook = "roles/k8s.yml"
#Redefine defaults
ansible.extra_vars = {
k8s_cluster_name: K8S_NAME,
k8s_master_admin_user: "vagrant",
k8s_master_admin_group: "vagrant",
k8s_master_apiserver_advertise_address: "#{IP_BASE}#{i + 10}",
k8s_master_node_name: "k8s-m-#{i}",
k8s_node_public_ip: "#{IP_BASE}#{i + 10}"
}
end
end
end
(1..NODES_NUM).each do |j|
config.vm.define "k8s-n-#{j}" do |node|
node.vm.box = IMAGE_NAME
node.vm.network "private_network", ip: "#{IP_BASE}#{j + 10 + MASTERS_NUM}"
node.vm.hostname = "k8s-n-#{j}"
node.vm.provider "virtualbox" do |v|
v.memory = NODES_MEM
v.cpus = NODES_CPU
#v.customize ["modifyvm", :id, "--cpuexecutioncap", "20"]
end
node.vm.provision "ansible" do |ansible|
ansible.playbook = "roles/k8s.yml"
#Redefine defaults
ansible.extra_vars = {
k8s_cluster_name: K8S_NAME,
k8s_node_admin_user: "vagrant",
k8s_node_admin_group: "vagrant",
k8s_node_public_ip: "#{IP_BASE}#{j + 10 + MASTERS_NUM}"
}
end
end
end
end