Zack Williams | fab1045 | 2019-08-15 15:50:29 -0700 | [diff] [blame^] | 1 | # -*- 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 |
| 11 | echo "Formatting and mounting /dev/vda, vdb on /mnt/ceph and /mnt/local" |
| 12 | parted -s /dev/vda \ |
| 13 | mklabel gpt \ |
| 14 | mkpart primary ext4 1MiB 100% |
| 15 | |
| 16 | sync |
| 17 | mkfs.ext4 -q -m 2 -F /dev/vda1 |
| 18 | |
| 19 | parted -s /dev/vdb \ |
| 20 | mklabel gpt \ |
| 21 | mkpart primary ext4 1MiB 20GiB \ |
| 22 | mkpart primary ext4 20GiB 100% |
| 23 | |
| 24 | sync |
| 25 | mkfs.ext4 -q -m 2 -F /dev/vdb1 |
| 26 | mkfs.ext4 -q -m 2 -F /dev/vdb2 |
| 27 | |
| 28 | parted -s /dev/vdc \ |
| 29 | mklabel gpt \ |
| 30 | mkpart primary ext4 1MiB 20GiB \ |
| 31 | mkpart primary ext4 20GiB 100% |
| 32 | |
| 33 | sync |
| 34 | mkfs.ext4 -q -m 2 -F /dev/vdc1 |
| 35 | mkfs.ext4 -q -m 2 -F /dev/vdc2 |
| 36 | |
| 37 | mkdir -p /mnt/ceph |
| 38 | mkdir -p /mnt/local-storage/hdd/vdb1 |
| 39 | mkdir -p /mnt/local-storage/hdd/vdb2 |
| 40 | mkdir -p /mnt/local-storage/ssd/vdc1 |
| 41 | mkdir -p /mnt/local-storage/ssd/vdc2 |
| 42 | |
| 43 | echo "/dev/vda1 /mnt/ceph ext4 defaults 0 0" | sudo tee -a /etc/fstab |
| 44 | echo "/dev/vdb1 /mnt/local-storage/hdd/vdb1 ext4 defaults 0 0" | sudo tee -a /etc/fstab |
| 45 | echo "/dev/vdb2 /mnt/local-storage/hdd/vdb2 ext4 defaults 0 0" | sudo tee -a /etc/fstab |
| 46 | echo "/dev/vdc1 /mnt/local-storage/ssd/vdc1 ext4 defaults 0 0" | sudo tee -a /etc/fstab |
| 47 | echo "/dev/vdc2 /mnt/local-storage/ssd/vdc2 ext4 defaults 0 0" | sudo tee -a /etc/fstab |
| 48 | mount -a |
| 49 | EOF |
| 50 | |
| 51 | |
| 52 | Vagrant.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 |
| 77 | end |
| 78 | |