-
Notifications
You must be signed in to change notification settings - Fork 46
/
Vagrantfile
108 lines (88 loc) · 4.37 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
107
108
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
require 'fileutils'
# Modify these in the variables.yaml file... they are described there in gory detail...
# This will get copied down later to synch/shared/variables... and read by the controlplane.sh etc...
settingsFile = "variables.yaml" || ENV["VAGRANT_VARIABLES"]
puts "[Vagrantfile] Loading settings from #{settingsFile}"
FileUtils.cp(settingsFile, "sync/shared/variables.yaml")
settings = YAML.load_file settingsFile
kubernetes_version=settings["kubernetes_version"]
k8s_linux_kubelet_nodeip=settings['k8s_linux_kubelet_nodeip']
pod_cidr=settings['pod_cidr']
calico_version=settings['calico_version']
containerd_version=settings['containerd_version']
linux_ram = settings['linux_ram']
linux_cpus = settings['linux_cpus']
windows_ram = settings['windows_ram']
windows_cpus = settings['windows_cpus']
windows_node_ip = settings['windows_node_ip']
cni = settings['cni']
Vagrant.configure(2) do |config|
puts "[Vagrantfile] Using Kubernetes version: #{kubernetes_version}"
puts "[Vagrantfile] Using Kubernetes CNI implementation: #{cni}"
# LINUX Control Plane
config.vm.define :controlplane do |controlplane|
controlplane.vm.host_name = "controlplane"
controlplane.vm.box = "roboxes/ubuntu2004"
controlplane.vm.network :private_network, ip:"#{k8s_linux_kubelet_nodeip}"
controlplane.vm.provider :virtualbox do |vb|
vb.memory = linux_ram
vb.cpus = linux_cpus
end
controlplane.vm.synced_folder "./sync/shared", "/var/sync/shared"
controlplane.vm.synced_folder "./forked", "/var/sync/forked"
controlplane.vm.synced_folder "./sync/linux", "/var/sync/linux"
### This allows the node to default to the right IP i think....
# 1) this seems to break the ability to get to the internet
controlplane.vm.provision :shell, privileged: false, path: "sync/linux/controlplane.sh", args: "#{kubernetes_version} #{k8s_linux_kubelet_nodeip} #{pod_cidr}"
# TODO shoudl we pass KuberneteVersion to calico agent exe? and also service cidr if needed?
# dont run as priveliged cuz we need the kubeconfig from regular user
if cni == "calico" then
puts "[Vagrantfile] Provisioning controlplane with Calico: #{calico_version}"
controlplane.vm.provision "shell", path: "sync/linux/calico-0.sh", args: "#{pod_cidr} #{calico_version}"
else
controlplane.vm.provision "shell", path: "sync/linux/antrea-0.sh"
end
end
# WINDOWS WORKER (win server 2019)
config.vm.define :winw1 do |winw1|
winw1.vm.host_name = "winw1"
winw1.vm.box = "sig-windows-dev-tools/windows-2019"
winw1.vm.box_version = "1.0"
winw1.vm.provider :virtualbox do |vb|
vb.memory = windows_ram
vb.cpus = windows_cpus
vb.gui = false
end
winw1.vm.network :private_network, ip:"#{windows_node_ip}"
winw1.vm.synced_folder ".", "/vagrant", disabled:true
winw1.vm.synced_folder "./sync/shared", "C:/sync/shared"
winw1.vm.synced_folder "./sync/windows/", "C:/sync/windows/"
winw1.vm.synced_folder "./forked", "C:/forked/"
winw1.winrm.username = "vagrant"
winw1.winrm.password = "vagrant"
if not File.file?(".lock/joined") then
# Update containerd
puts "[Vagrantfile] Provisioning winw1 node with Calico: #{calico_version}; containerd: #{containerd_version}"
winw1.vm.provision "shell", path: "sync/windows/0-containerd.ps1", args: "#{calico_version} #{containerd_version}", privileged: true
# Joining the controlplane
winw1.vm.provision "shell", path: "sync/windows/forked.ps1", args: "#{kubernetes_version}", privileged: true
winw1.vm.provision "shell", path: "sync/shared/kubejoin.ps1", privileged: true #, run: "never"
else
if not File.file?(".lock/cni") then
if cni == "calico" then
# we don't need to run Calico agents as service now,
# calico will be installed as a HostProcess container
# installs both felix and node
#winw1.vm.provision "shell", path: "sync/windows/0-calico.ps1", privileged: true
#winw1.vm.provision "shell", path: "sync/windows/1-calico.ps1", privileged: true
else
winw1.vm.provision "shell", path: "sync/windows/0-antrea.ps1", privileged: true #, run: "always"
winw1.vm.provision "shell", path: "sync/windows/1-antrea.ps1", privileged: true, args: "#{windows_node_ip}" #, run: "always"
end
end
end
end
end