forked from friedrichwilken/sig-windows-dev-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
114 lines (99 loc) · 5.16 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
109
110
111
112
113
114
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# Modify these in the variables.yaml file... they are described there in gory detail...
settingsFile = ENV["VAGRANT_VARIABLES"] || 'sync/shared/variables.yaml'
settings = YAML.load_file settingsFile
k8s_linux_registry=settings['k8s_linux_registry']
k8s_linux_kubelet_deb=settings['k8s_linux_kubelet_deb']
k8s_linux_apiserver=settings['k8s_linux_apiserver']
k8s_linux_kubelet_nodeip=settings['k8s_linux_kubelet_nodeip']
kubernetes_compatibility=settings['kubernetes_compatibility']
overwrite_linux_bins = settings['overwrite_linux_bins']
overwrite_windows_bins = settings['overwrite_windows_bins'] ? "-OverwriteBins" : ""
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 "cni:"
puts cni
# LINUX Control Plane
config.vm.define :controlplane do |controlplane|
controlplane.vm.host_name = "controlplane"
controlplane.vm.box = "roboxes/ubuntu2004"
# the default:
# controlplane.vm.box = "ubuntu/focal64"
# better because its available on vmware and virtualbox:
# controlplane.vm.box = "bento/ubuntu-18.04"
controlplane.vm.network :private_network, ip:"#{k8s_linux_kubelet_nodeip}"
controlplane.vm.provider :virtualbox do |vb|
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"
vb.memory = linux_ram
vb.cpus = linux_cpus
end
### 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: true, inline: "sudo ip route add default via 10.20.30.10"
controlplane.vm.provision :shell, privileged: false, path: "sync/linux/controlplane.sh", args: "#{overwrite_linux_bins} #{k8s_linux_registry} #{k8s_linux_kubelet_deb} #{k8s_linux_apiserver} #{k8s_linux_kubelet_nodeip}"
# 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
controlplane.vm.provision "shell", path: "sync/linux/calico-0.sh"
else
controlplane.vm.provision "shell", path: "sync/linux/antrea-0.sh"
end
controlplane.vm.provision :shell, privileged: false, inline: "kubectl create -f /var/sync/linux/smoke-test.yaml"
end
# WINDOWS WORKER (win server 2019)
config.vm.define :winw1 do |winw1|
winw1.vm.host_name = "winw1"
winw1.vm.box = "StefanScherer/windows_2019"
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.vm.provider :virtualbox do |vb|
vb.memory = windows_ram
vb.cpus = windows_cpus
vb.gui = false
end
if not File.file?("joined") then
winw1.vm.provision "shell", path: "sync/windows/hyperv.ps1", privileged: true
winw1.vm.provision :reload
winw1.vm.provision "shell", path: "sync/windows/containerd1.ps1", privileged: true #, run: "never"
winw1.vm.provision :reload
winw1.vm.provision "shell", path: "sync/windows/containerd2.ps1", privileged: true #, run: "never"
winw1.vm.provision "shell", path: "forked/PrepareNode.ps1", privileged: true, args: "-KubernetesVersion #{kubernetes_compatibility} -WindowsNodeIP #{windows_node_ip} -ContainerRuntime containerD #{overwrite_windows_bins} " #, run: "never"
winw1.vm.provision "shell", path: "sync/shared/kubejoin.ps1", privileged: true #, run: "never"
winw1.vm.provision "shell", path: "sync/windows/ssh.ps1", privileged: true #, run: "never"
else
# TODO should we pass KuberneteVersion to calico agent exe? and also service cidr if needed?
if cni == "calico" then
if not File.file?("cni") then
# installs both felix and node
winw1.vm.provision "shell", path: "forked/0-calico.ps1", privileged: true #, run: "always"
winw1.vm.provision :reload
winw1.vm.provision "shell", path: "forked/1-calico.ps1", privileged: true #, run: "always"
# only run final provisioning step if 'provisioned' is there...
else
winw1.vm.provision "shell", path: "forked/2-calico.ps1", privileged: true #, run: "always"
winw1.vm.provision "shell", path: "forked/3-calico.ps1", privileged: true #, run: "always"
end
else
if File.file?("cni") then
print("cni already done for antrea")
else
# Experimental at the moment...
winw1.vm.provision "shell", path: "forked/0-antrea.ps1", privileged: true #, run: "always"
winw1.vm.provision "shell", path: "forked/1-antrea.ps1", privileged: true, args: "-KubernetesVersion #{kubernetes_compatibility}" #, run: "always"
end
end
end
end
end