Transparent Service Migration To The Cloud

Transcription

Transparent Service Migration to the CloudClone existing VMs to CloudStack/OpenStack templates without user downtimeCloudOpen – Dublin 2015

#whoamiName: Tim MackeyCurrent roles: XenServer Community Manager and Evangelist; occasional coderCool things I’ve done Designed laser communication systems Early designer of retail self-checkout machines Embedded special relativity algorithms into industrial control systemFind me Twitter: @XenServerArmySlideShare: slideshare.net/TimMackeyLinkedIn: https://www.linkedin.com/in/mackeytimGitHub: https://github.com/xenserverarmy

Define “VM Migration”What people thinkTemplate VM moves from source host to destinationWhy it doesn’t work “to the cloud” Incompatible host micro-architectureLack of control over networkingDo we really want a VM HALT?Long distance ARPReally want “template migration”TemplateTemplate

CloudStack view of Templates

Template Management in CloudStackMy first template Existing VM or appliance in VHD format – compression optional Need to have HTTP server Set secstorage.allowed.internal.sites if private cloudCreation options Register template in UI Templates Register Template Upload using registerTemplate API user/registerTemplate.html Clone from CloudStack instance Stop instance View Volumes Create Template

Key Template AttributesObvious Hypervisor Operating system type ZoneNot so obvious IsDynamicallyScalable Hypervisor toolsPasswordEnabled CloudStack sets root pwdSSHKeyEnabled Can post configureRequiresHVM Defines virtualization mode

VM Password and SSH Key Management ChallengesObtain information from Virtual Router IP is obtained from leases Scripts use wget Assumes sysinit not systemdWhat to fix – varies by OS? CentOS 7 defaults to curl not wget CentOS 7 is systemd need unit files CentOS 7 may use NetworkManager

OpenStack view of Templates

Template Management in Horizon and GlanceMy first template Existing VM or appliance in hypervisor specific disk format XenServer: VHD format with file named 0.VHD and tgzCreation options Register image in Horizon System- Images- Create Image Upload using Glance API pi.html Clone from running instance Compute- Instances- Create Snapshot

Key Image AttributesObvious (x-image-meta-) Owner Flavor information (Disk and RAM) RegionNot so obvious (x-image-meta-property) hypervisor type Xen for XenServer vm mode PV vs. HVM os type Linux or Windows for swap space

Handling Critical Initial VM ConfigurationObtain information from instance configuration drive ISO 9660 or VFAT drive assigned to instance at boot Supported with libvirt, XenServer, vSphere and Hyper-V Works with custom scripts and cloud-initUsing a configuration drive Specify per instance on nova boot --config-drive true Force for all instances in nova config force config driver true Pass both meta information and userdata

How the tooling works

Packer is Awesome!!http://packer.io

Core Packer ConceptsBuilder Responsible for creation of VM image Connects to virtual infrastructure Default supports vSphere, OpenStack, AMI, VirtualBox, QEMU, Docker No XenServer needed to fix that ;)Provisioner Runs post-build activitiesPost-Processor Takes VM image artifact and transforms it In our case upload to CloudStack or OpenStack needed to fix that too ;)Check versions – interfaces changed with packer 0.8!

Key Activities Occurring During Template Build from ISO1. Download ISO into ISO SR (if not already present)2. Attach ISO to VM object and boot3. Instruct installer to user kickstart file4. Installer does its thing and shuts VM down5. Upon shutdown, swap installer ISO for XenServer tools ISO6. Install ISO and shutdown7. Detect shutdown and run Provisioners8. Export and import into the cloud as template

xenserver-iso builderCreates a new XenServer image from an ISOKey parameters Host connection ISO location Boot commandsArtifact output type xva, vdi raw, vhd, vhd rawKnown limitations Linux only (uses SSH) Requires NFS shared storage for export

xenserver-vm builderCreates a new XenServer image from existing running VMKey parameters Host connectionVM nameCleanse commandCleanse scriptsArtifact output type xva, vdi raw, vhd, vhd rawKnown limitations Linux only (uses SSH) Requires NFS shared storage for export

cloudstack-xenserver post-processorCreates a new CloudStack template from xenserver buildersKey parameters CloudStack API keys Zone, OS type Script configurationArtifact input xenserver-iso, xenserver-vm

openstack-xenserver post-processorCreates a new OpenStack Glance image from xenserver buildersKey parameters Keystone URL and credentials Project name, region, and instance name Script configurationArtifact input xenserver-iso, xenserver-vm

Key Activities Occurring During Service Migration1. Snapshot of existing VM to minimize downtime2. Detect if VM is PV or HVM and flag accordingly3. Copy snapshot to NFS SR to collapse any snapshot chains4. Connect primary network to HIMN to ensure no machine collision5. Use VNC to reconfigure network and connect to XenServer DHCP server6. Copy and run cleanse scripts which shutdown clone when complete7. Detect shutdown and run Provisioners8. Export and import into cloud as template

Demo time .When live 10 minutes to move a live service to the cloud, but infra broke so video!

The Service to Migrate – Piwigohttp://piwigo.org

The Original Topology

The Cloud Topology with Original Data Store Intact

Bringing “Migration” all Together with an ADCUsersMy Cloud

Confirm the Migration and Iterate1. Verify service migrated correctly2. Iterate and resolve any issues3. Scale the service Let’s add more capacity4. Add service to original load balancer Don’t forget to adjust session weights5. Decommission original service

Questions?

In our case upload to CloudStack or OpenStack needed to fix that too ;) Check versions – interfaces changed with packer 0.8! Key Activities Occurring During Template Build from ISO 1. Download ISO into ISO SR (if not