blob: 2c222073c141046d1b4ec8b57a03aea8eaf362bd [file] [log] [blame]
Zack Williamsfab10452019-08-15 15:50:29 -07001# -*- mode: ruby -*-
2# vi: set ft=ruby :
3#
4# kubespray-installer test Vagrantfile
5
6$num_instances = 3
7
8# Script to format/mount vda volume for ceph testing
9# https://www.vagrantup.com/docs/provisioning/shell.html
10$vdisk_setup = <<-EOF
11echo "Formatting and mounting /dev/vda, vdb on /mnt/ceph and /mnt/local"
12parted -s /dev/vda \
13 mklabel gpt \
14 mkpart primary ext4 1MiB 100%
15
16sync
17mkfs.ext4 -q -m 2 -F /dev/vda1
18
19parted -s /dev/vdb \
20 mklabel gpt \
21 mkpart primary ext4 1MiB 20GiB \
22 mkpart primary ext4 20GiB 100%
23
24sync
25mkfs.ext4 -q -m 2 -F /dev/vdb1
26mkfs.ext4 -q -m 2 -F /dev/vdb2
27
28parted -s /dev/vdc \
29 mklabel gpt \
30 mkpart primary ext4 1MiB 20GiB \
31 mkpart primary ext4 20GiB 100%
32
33sync
34mkfs.ext4 -q -m 2 -F /dev/vdc1
35mkfs.ext4 -q -m 2 -F /dev/vdc2
36
37mkdir -p /mnt/ceph
38mkdir -p /mnt/local-storage/hdd/vdb1
39mkdir -p /mnt/local-storage/hdd/vdb2
40mkdir -p /mnt/local-storage/ssd/vdc1
41mkdir -p /mnt/local-storage/ssd/vdc2
42
43echo "/dev/vda1 /mnt/ceph ext4 defaults 0 0" | sudo tee -a /etc/fstab
44echo "/dev/vdb1 /mnt/local-storage/hdd/vdb1 ext4 defaults 0 0" | sudo tee -a /etc/fstab
45echo "/dev/vdb2 /mnt/local-storage/hdd/vdb2 ext4 defaults 0 0" | sudo tee -a /etc/fstab
46echo "/dev/vdc1 /mnt/local-storage/ssd/vdc1 ext4 defaults 0 0" | sudo tee -a /etc/fstab
47echo "/dev/vdc2 /mnt/local-storage/ssd/vdc2 ext4 defaults 0 0" | sudo tee -a /etc/fstab
48mount -a
49EOF
50
51
52Vagrant.configure("2") do |config|
53 config.vm.box = "bento/ubuntu-16.04"
54
55 (1..$num_instances).each do |i|
56 config.vm.define vm_name = "k8s-%02d" % i do |config|
57 config.vm.hostname = vm_name
58
59 config.vm.provider :libvirt do |lv|
60 lv.memory = 16384
61 lv.cpus = 8
62 lv.nested = true
63 # additional disks for testing storage, shows up as `vd[a-c]` in the VM
64 lv.storage :file, :size => '40G'
65 lv.storage :file, :size => '40G'
66 lv.storage :file, :size => '40G'
67 end
68
69 config.vm.provision "shell", inline: "swapoff -a"
70 config.vm.provision "shell", inline: $vdisk_setup
71
72 ip = "10.90.0.#{i+100}"
73 config.vm.network :private_network, ip: ip
74
75 end
76 end
77end
78