saltconf14 - matthew williams, flowroute - salt virt for linux contatiners and virtualization...
DESCRIPTION
This SaltConf14 talk by Matthew Williams of Flowroute shows the power of Salt Virt and Runner for creating and managing VMs and Linux containers. A demonstration of the Salt lxc module shows the simplicity with which containers and VMs can be created and configured.TRANSCRIPT
![Page 1: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/1.jpg)
![Page 2: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/2.jpg)
Salt Virt for Linux Containers and Virtualization Management
![Page 3: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/3.jpg)
Matthew Williams [email protected]
![Page 4: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/4.jpg)
• Enterprise Class VoIP Provider!• Manage about 100 minions… and growing!• Adopted Salt in 2013
![Page 5: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/5.jpg)
Salt and Virtualization
• Two Unique Systems!• virt: Virtualization via libvirt (e.g., KVM, VMware)!• lxc: Linux Containers
![Page 6: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/6.jpg)
virt
![Page 7: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/7.jpg)
virt
• virt execution module!• create, destroy, start, stop VMs!• obtain information about VMs!
• virt runner!• orchestrate deployment of VMs!• pre-accept minion keys for VMs
![Page 8: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/8.jpg)
Preparing the Host
• Host system with libvirt and python-libvirt installed!• Network bridge configured (On Ubuntu libvirt-bin
package does this for you)!• default nic profile in pillar
or minion config:virt.nic:! default:! eth0:! bridge: virbr0! model: virtio
![Page 9: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/9.jpg)
Preparing an Image
• A base VM image is needed.!• May be built with vmbuilder:
vmbuilder kvm ubuntu --suite precise --flavour virtual - \!--dest test_img --ppa saltstack --addpkg salt-minion
• Preinstall salt-minion if possible!• Most cloud-ready images will also work
![Page 10: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/10.jpg)
Creating VMs
salt-run virt.init test 1 256 salt://test_img.qcow nic=default
• selects the least loaded hyper (based on memory)!• caches and clones the image!• installs salt-minion (if needed)!• configures the minion and pre signs its key!• starts the VM
![Page 11: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/11.jpg)
Managing VMs
salt-run virt.pause test!salt-run virt.resume test
• pause and resume
• power off and restartsalt-run virt.force_off test!salt-run virt.start test
salt-run virt.reset test
![Page 12: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/12.jpg)
Managing VMs
salt-run virt.purge test
• delete forever
![Page 13: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/13.jpg)
Documentation
http:/docs.saltstack.com/topics/tutorials/cloud_controller.html!!http://docs.saltstack.com/ref/runners/all/salt.runners.virt.html
![Page 14: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/14.jpg)
lxc: Linux Containers
![Page 15: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/15.jpg)
lxc
• lxc execution module!• create, destroy, start, stop containers!• obtain information about containers!
• lxc runner (develop branch only)!• orchestrate deployment of containers!• pre-accept minion keys for containers
![Page 16: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/16.jpg)
Linux Containers
• Kernel containment features are utilized, including:!• Namespaces (ipc, uts, mount, pid, network and user)!• Chroots!• cgroups!
• More like a virtual environment than a virtual machine
More Info: www.linuxcontainers.org
![Page 17: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/17.jpg)
Preparing the Host
• Install the lxc package and ensure the service is running
lxc:! pkg:! - installed! service:! - running! - require:! - pkg: lxc
![Page 18: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/18.jpg)
Preparing the Host
• configure lxc.nic and lxc.profile in pillar (or minion config)
lxc.nic:! default:! eth0:! link: lxcbr0! type: veth!!lxc.profile:! ubuntu:! template: ubuntu! backing: lvm! vgname: lxc! size: 1G
![Page 19: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/19.jpg)
The LXC Runner
salt-run lxc.init name host=minion_id [cpuset=cgroups_cpuset] \ [cpushare=cgroups_cpushare] [memory=cgroups_memory] \ [nic=nic_profile] [profile=lxc_profile] \ [nic_opts=nic_opts] [start=(true|false)] \ [seed=(true|false)] [install=(true|false)] \ [config=minion_config]
![Page 20: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/20.jpg)
Creating a Container
salt-run lxc.init test host=host_minion \! profile=ubuntu memory=256
• Utilizes the ubuntu lxc template (many are available)!- Pulls an ubuntu image, if needed, and caches it!
• Installs salt-minion and pre-seeds config and keys!• Starts the container
![Page 21: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/21.jpg)
Managing Containers
salt-run lxc.freeze test!salt-run lxc.unfreeze test
• freeze and unfreeze
• power off and restartsalt-run lxc.stop test!salt-run lxc.start test
![Page 22: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/22.jpg)
Managing Containers
salt-run lxc.purge test
• delete forever
![Page 23: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/23.jpg)
Documentation
http://docs.saltstack.com/ref/runners/all/salt.runners.lxc.html!!http://docs.saltstack.com/ref/modules/all/salt.modules.lxc.html
![Page 24: SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners and virtualization management](https://reader034.vdocuments.net/reader034/viewer/2022052618/554f8eabb4c905435d8b4f6a/html5/thumbnails/24.jpg)
We’re Hiring
flowroute.com/jobs