-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile
116 lines (87 loc) · 3.2 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
115
116
# coding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 2.0.0"
# just a single node is required
NODES = ENV['NODES'] || 1
# Memory & CPUs
MEM = ENV['MEM'] || 6144
CPUS = ENV['CPUS'] || 2
# User Data Mount
#SRCDIR = ENV['SRCDIR'] || "/home/"+ENV['USER']+"/test"
SRCDIR = ENV['SRCDIR'] || "/tmp/vagrant"
DSTDIR = ENV['DSTDIR'] || "/home/vagrant/data"
# Management
GROWPART = ENV['GROWPART'] || "true"
#No longer supported
# Minikube Variables
#KUBERNETES_VERSION = ENV['KUBERNETES_VERSION'] || "1.14.0"
$growpart = <<SCRIPT
#!/bin/bash
if [[ -b /dev/vda3 ]]; then
sudo growpart /dev/vda 3
sudo resize2fs /dev/vda3
elif [[ -b /dev/sda3 ]]; then
sudo growpart /dev/sda 3
sudo resize2fs /dev/sda3
fi
SCRIPT
required_plugins = %w(vagrant-sshfs vagrant-vbguest vagrant-libvirt)
required_plugins.each do |plugin|
need_restart = false
unless Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
need_restart = true
end
exec "vagrant #{ARGV.join(' ')}" if need_restart
end
def configureVM(vmCfg, hostname, cpus, mem, srcdir, dstdir)
# Image is 64 Gb
vmCfg.vm.box = "generic/ubuntu1804"
vmCfg.vm.hostname = hostname
vmCfg.vm.network "private_network", type: "dhcp", :model_type => "virtio", :autostart => true
vmCfg.vm.synced_folder '.', '/vagrant', disabled: true
# sync your laptop's development with this Vagrant VM
vmCfg.vm.synced_folder srcdir, dstdir, type: "rsync", rsync__exclude: ".git/", create: true
# First Provider - Libvirt
vmCfg.vm.provider "libvirt" do |provider, override|
provider.memory = mem
provider.cpus = cpus
provider.driver = "kvm"
provider.disk_bus = "scsi"
provider.machine_virtual_size = 64
provider.video_vram = 64
override.vm.synced_folder srcdir, dstdir, type: 'sshfs', ssh_opts_append: "-o Compression=yes", sshfs_opts_append: "-o cache=no", disabled: false, create: true
end
vmCfg.vm.provider "virtualbox" do |provider, override|
provider.memory = mem
provider.cpus = cpus
provider.customize ["modifyvm", :id, "--cableconnected1", "on"]
override.vm.synced_folder srcdir, dstdir, type: 'virtualbox', create: true
end
# Script to prepare the VM
vmCfg.vm.provision "shell", inline: $growpart, privileged: false if GROWPART == "true"
vmCfg.vm.provision "shell", path: "crio.sh", privileged: false
vmCfg.vm.provision "shell", path: "kubernetes.sh", privileged: false
vmCfg.vm.provision "shell", path: "kubevirt.sh", privileged: false
vmCfg.vm.provision "shell", path: "rancher-local-path-provisioner.sh", privileged: false
vmCfg.vm.provision "shell", path: "cdi.sh", privileged: false
vmCfg.vm.provision "shell", path: "kata.sh", privileged: false
vmCfg.vm.provision "shell", path: "demo.sh", privileged: false
return vmCfg
end
# Entry point of this Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vbguest.auto_update = false
1.upto(NODES.to_i) do |i|
hostname = "kubernetes-vagrant-%02d" % [i]
cpus = CPUS
mem = MEM
srcdir = SRCDIR
dstdir = DSTDIR
config.vm.define hostname do |vmCfg|
vmCfg = configureVM(vmCfg, hostname, cpus, mem, srcdir, dstdir)
end
end
end