-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
executable file
·57 lines (53 loc) · 1.93 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
NODES = 2
IMAGE_NAME = "generic/ubuntu2004"
CONTROLPLANE_MEMORY=4096
WORKER_MEMORY=2048
NETWORK_PREFIX="192.168.165"
VM_GROUP_NAME="cka"
Vagrant.configure("2") do |config|
#config.ssh.insert_key = false
config.vm.define "k8s-controlplane" do |controlplane|
controlplane.vm.box = IMAGE_NAME
controlplane.vm.network "private_network", ip: "#{NETWORK_PREFIX}.10"
controlplane.vm.hostname = "k8s-controlplane"
controlplane.vm.provider :libvirt do |vb|
vb.title = "k8s-controlplane"
vb.memory = CONTROLPLANE_MEMORY
vb.cpus = 2
end
controlplane.vm.provision "ansible" do |ansible|
ansible.playbook = "kubernetes-setup/k8s-controlplane-playbook.yml"
ansible.groups = {
"controlplane" => ["k8s-controlplane"]
}
ansible.extra_vars = {
node_ip: "#{NETWORK_PREFIX}.10",
k8s_hostname: "k8s-controlplane"
}
end
end
(1..NODES).each do |i|
config.vm.define "k8s-worker-#{i}" do |node|
node.vm.box = IMAGE_NAME
node.vm.network "private_network", ip: "#{NETWORK_PREFIX}.#{i + 10}"
node.vm.hostname = "k8s-worker-#{i}"
node.vm.provider :libvirt do |vb|
vb.title = "k8s-worker-#{i}"
vb.memory = WORKER_MEMORY
vb.cpus = 2
end
node.vm.provision "ansible" do |ansible|
ansible.playbook = "kubernetes-setup/k8s-worker-playbook.yml"
ansible.groups = {
"workers" => ["k8s-worker-[1:#{NODES}]"]
}
ansible.extra_vars = {
node_ip: "#{NETWORK_PREFIX}.#{i + 10}",
k8s_hostname: "k8s-worker-#{i}"
}
end
end
end
end