Virtualization
History, KVM and Openstack
IaaS/PaaS/SaaS, Ganeti, Cloud Images and Packer
History, KVM and Openstack
IaaS/PaaS/SaaS, Ganeti, Cloud Images and Packer
Software, firmware or hardware that creates and runs virtual machines.
Which hypervisor type does KVM fall under?
Open Source hypervisor based on Linux
KVM has a lot of options
# Create a virtual disk file
$ qemu-img create -f qcow2 disk.img 10g
# Start a VM up and boot to an ISO
$ qemu-system-x86_64 -hda disk.img -cdrom \
/path/to/CentOS-6.6-x86_64-minimal.iso -boot d -m 1024m
/usr/libexec/qemu-kvm -name instance-00000baa -S -M rhel6.6.0 -cpu
Westmere,+rdtscp,+pdpe1gb,+dca,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pclmuldq,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme
-enable-kvm -m 512 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid
96bea55c-6d58-4dcf-bc52-09aed81c0cee -smbios type=1,manufacturer=RDO
Project,product=OpenStack
Nova,version=2014.1.3-3.el6,serial=44454c4c-3400-1051-8059-c7c04f534b31,uuid=96bea55c-6d58-4dcf-bc52-09aed81c0cee
-nodefconfig -nodefaults -chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/instance-00000baa.monitor,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew
-no-kvm-pit-reinjection -no-shutdown -device
piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
file=/var/lib/nova/instances/96bea55c-6d58-4dcf-bc52-09aed81c0cee/disk,if=none,id=drive-virtio-disk0,format=qcow2,cache=none
-device
virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
-drive
file=/var/lib/nova/instances/96bea55c-6d58-4dcf-bc52-09aed81c0cee/disk.swap,if=none,id=drive-virtio-disk1,format=qcow2,cache=none
-device
virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,id=virtio-disk1
-netdev tap,fd=35,id=hostnet0,vhost=on,vhostfd=39 -device
virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:35:5f:f4,bus=pci.0,addr=0x3
-chardev
file,id=charserial0,path=/var/lib/nova/instances/96bea55c-6d58-4dcf-bc52-09aed81c0cee/console.log
-device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charserial1
-device isa-serial,chardev=charserial1,id=serial1 -device usb-tablet,id=input0
-vnc 10.1.0.114:11 -k en-us -vga cirrus -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -msg timestamp=on
Micro-kernel hypervisor for Linux or BSD
Xen Project runs in a more privileged CPU state than any other software on the machine.
KVM | Xen |
---|---|
Less mature | More mature |
Runs like a normal unix app | Blackbox feel for how it works |
Always been in mainline | Had trouble getting into mainline Linux |
Requires CPU support | Doesn't require CPU support |
Development is very active and growing | Development has slowed a bit |
Used by newer cloud providers (i.e. GCE, DigitalOcean) | Used by Amazon EC2 |
Libvirt is an open source API daemon that standardizes management of various virtualization platforms.
Virtual computing platform that typically includes automated methods for deploying virtual machines on a set of physical machines
Examples:
A platform that provides customers the ability to develop, run and manage web applications without the complexity of building and maintaining the underlying infrastructure
Typically layered on top of IaaS
Examples:
Software delivery model in which software is provided on a subscription basis and centrally hosted. Also referred to as "on-demand software".
Examples:
Open source cloud computing platform
Distributed replicated storage system (think RAID1 over the network)
A feature that allows a virtual machine to move from one host to another host while staying online.
A copy of an operating system including the entire state of the computer system stored in a non-volatile form such as a file.
Image Files | Block Devices |
---|---|
Easy to move around and create | Requires use of LVM or other block device tools |
Can have a performance hit | Typically has better performance |
Offer more features such as compression | You can't 'overcommit' space with LVM |
Various tools exist to create images. Some are distribution specific while others aren't.
Amazon EC2 | Digital Ocean |
Docker | GCE |
Openstack | Parallels |
QEMU (kvm) | Virtual Box |
VMWare |
This varies depending on which builder you use. The following is an example for the QEMU builder
{
"builders": [
{
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos-7.0/ks-openstack.cfg",
"<enter><wait>"
],
"accelerator": "kvm",
"boot_wait": "10s",
"disk_size": 2048,
"headless": true,
"http_directory": "http",
"iso_checksum": "df6dfdd25ebf443ca3375188d0b4b7f92f4153dc910b17bccc886bd54a7b7c86",
"iso_checksum_type": "sha256",
"iso_url": "{{user `mirror`}}/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-NetInstall.iso",
"output_directory": "packer-centos-7.0-x86_64-openstack",
"qemuargs": [ [ "-m", "1024m" ] ],
"qemu_binary": "qemu-kvm",
"shutdown_command": "echo 'centos'\|sudo -S /sbin/halt -h -p",
"ssh_password": "centos",
"ssh_port": 22,
"ssh_username": "centos",
"ssh_wait_timeout": "10000s",
"type": "qemu",
"vm_name": "packer-centos-7.0-x86_64"
}
],
"provisioners": [
{
"environment_vars": [
"CHEF_VERSION={{user `chef_version`}}"
],
"execute_command": "echo 'centos' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"scripts": [
"scripts/centos/osuosl.sh",
"scripts/centos/fix-slow-dns.sh",
"scripts/common/sshd.sh",
"scripts/common/vmtools.sh",
"scripts/common/chef.sh",
"scripts/centos/openstack.sh",
"scripts/centos/cleanup.sh",
"scripts/common/minimize.sh"
],
"type": "shell"
}
],
"variables": {
"chef_version": "provisionerless",
"mirror": "http://centos.osuosl.org"
}
}
$ packer build centos-7.0-x86_64-openstack.json
qemu output will be in this color.
==> qemu: Downloading or copying ISO
qemu: Downloading or copying: http://centos.osuosl.org/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-NetInstall.iso
==> qemu: Creating hard drive...
==> qemu: Starting HTTP server on port 8081
==> qemu: Found port for SSH: 3213.
==> qemu: Looking for available port between 5900 and 6000
==> qemu: Found available VNC port: 5947
==> qemu: Starting VM, booting from CD-ROM
qemu: WARNING: The VM will be started in headless mode, as configured.
qemu: In headless mode, errors during the boot sequence or OS setup
qemu: won't be easily visible. Use at your own discretion.
==> qemu: Overriding defaults Qemu arguments with QemuArgs...
==> qemu: Waiting 10s for boot...
==> qemu: Connecting to VM via VNC
==> qemu: Typing the boot command over VNC...
==> qemu: Waiting for SSH to become available...
Shell | Run either inline or shell scripts |
File Uploads | Upload files and use shell scripts to move files around as needed |
Ansible | Provision using playbook and role files |
Chef Client | Connect to a chef server and run chef |
Chef Solo | Run a Chef solo run by pointing to local cookbooks or uploading them |
Puppet Masterless | Run local manifests and modules |
Puppet Server | Connect to a puppet server and run puppet |
Salt | Using Salt states, deploy a vm using Salt |