Replace Virtualbox usage with KVM

This commit is contained in:
Mark Burnett 2017-07-26 13:12:10 -05:00
parent c0cd056d1b
commit 729162fe72
7 changed files with 102 additions and 7 deletions

12
Vagrantfile vendored
View File

@ -2,7 +2,7 @@
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.box = "promenade/ubuntu1604"
config.vm.box_check_update = false
config.vm.provision :shell, privileged: true, inline:<<EOS
@ -13,10 +13,12 @@ apt-get update -qq
apt-get install -y -qq --no-install-recommends chrony
EOS
config.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = "2048"
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
config.vm.synced_folder ".", "/vagrant", :nfs => true
config.vm.provider "libvirt" do |lv|
lv.cpus = 2
lv.memory = "2048"
lv.nested = true
end
config.vm.define "n0" do |c|

View File

@ -4,8 +4,16 @@
### Deployment using Vagrant
Make sure you have [Vagrant](https://vagrantup.com) and
[VirtualBox](https://www.virtualbox.org/wiki/Downloads) installed.
Deployment using Vagrant uses KVM instead of Virtualbox due to better
performance of disk and networking, which both have significant impact on the
stability of the etcd clusters.
Make sure you have [Vagrant](https://vagrantup.com) installed, then
run `./tools/full-vagrant-setup.sh`, which will do the following:
* Install Vagrant libvirt plugin and its dependencies
* Install NFS dependencies for Vagrant volume sharing
* Install [packer](https://packer.io) and build a KVM image for Ubuntu 16.04
Generate the per-host configuration, certificates and keys to be used:

24
tools/build-vagrant-box.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -ex
WORKDIR=$(mktemp -d)
function cleanup {
rm -rf "${WORKDIR}"
}
trap cleanup EXIT
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
curl \
unzip
git clone https://github.com/jakobadam/packer-qemu-templates.git ${WORKDIR}
cd ${WORKDIR}/ubuntu
packer build -var-file=ubuntu1604.json ubuntu-vagrant.json
vagrant box add promenade/ubuntu1604 box/libvirt/ubuntu1604-1.box

9
tools/full-vagrant-setup.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -ex
SCRIPT_DIR=$(dirname $0)
$SCRIPT_DIR/install-vagrant-nfs-deps.sh
$SCRIPT_DIR/install-vagrant-libvirt.sh
$SCRIPT_DIR/install-packer.sh

21
tools/install-packer.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -ex
PACKER_VERSION=${PACKER_VERSION:-1.0.3}
WORKDIR=$(mktemp -d)
function cleanup {
rm -rf "${WORKDIR}"
}
trap cleanup EXIT
cd ${WORKDIR}
curl -Lo packer.zip https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip
unzip packer.zip
sudo mv packer /usr/local/bin/

View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -ex
sudo apt-get update
sudo apt-get build-dep -y \
ruby-libvirt
sudo apt-get install -y --no-install-recommends \
build-essential \
dnsmasq \
ebtables \
libvirt-bin \
libvirt-dev \
libxml2-dev \
libxslt-dev \
qemu \
ruby-dev \
zlib1g-dev
vagrant plugin install vagrant-libvirt

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -ex
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
nfs-common \
nfs-kernel-server \
portmap