Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Creating CentOS Template For CloudStack
1. Creating CentOS Template For
CloudStack
March 2014 Bangalore CloudStack Meetup @ InMobi
Shanker Balan
Managing Consultant
ShapeBlue India
@shankerbalan
2. www.ShapeBlue.com @shapeblue
“ShapeBlue are expert builders of public & private
clouds. They are the leading independent global
CloudStack / CloudPlatform integrator &
consultancy”
About ShapeBlue
4. www.ShapeBlue.com @shapeblue
Register ISO Installer CD/DVD
Launch Instance from ISO
Install OS
Customize / Optimize the Instance
Create Template from Instance
Register & Share Template
Agenda
5. www.ShapeBlue.com @shapeblue
A “template” is a base OS image for creating new instances
CentOS 5.x 64-bit is the default template shipped with CloudStack
Templates can be created by admin or by the user directly from
ISOs installer
Templates can also be uploaded by admin or by the user
Templates are Hypervisor specific
Xen (VHD), KVM (QCoW), VMware (OVA)
Templates are CPU architecture specific
32bit or 64bit
CloudStack Templates
6. www.ShapeBlue.com @shapeblue
Login as ‘Admin’ or ‘User’
Navigate to ‘Templates’ -> ‘Register ISO’
Add download URL to the nearest mirror
http://mirror.leapswitch.com/centos/6.5/isos/x86_64/CentOS-6.5-
x86_64-minimal.iso
http://mirror.leapswitch.com/centos/6.5/isos/i386/CentOS-6.5-i386-
minimal.iso
Set to Bootable with OS Type as CentOS 6.4 32bit or 64-bit
Register CentOS Installer ISO
7.
8. www.ShapeBlue.com @shapeblue
Create new instance using ‘Instances’ -> ‘Add Instances’
wizard
Choose the ISO and Hypervisor Type
Select compute offering
Choose data disk size
Give it a name
OS-version-arch (CentOS65-xen64)
Launch Instance and console
Create Instance From ISO
10. www.ShapeBlue.com @shapeblue
Complete OS Install using the Install Wizard (Anaconda)
Language
Time Zone
Keyboard
Disk Partitioning Layout
Root password
Package selection defaults to ‘minimal’
CentOS Minimal Installer runs in text mode
Network configuration not possible in text mode
OS Install
11. www.ShapeBlue.com @shapeblue
Use LVM
CloudStack will have root disk resize feature soon
LVM will allow for easy expansion
Use a simple partitioning scheme
/
/boot
swap
Create small sized Swap partition
256MB
Disk Layout Best Practices
17. www.ShapeBlue.com @shapeblue
Remove unneeded / insecure packages
NetworkManager, NFS, portmapper
Remove SSH host keys from /etc/ssh/
Create new guest user with sudo privileges
Disable the root user / reset root password
Clean yum cache
Truncate Logs / shell history
Remove
/etc/udev/rules.d/70-persistent-net.rules
Cleanup CentOS
18. www.ShapeBlue.com @shapeblue
Cloud-init
A set of init scripts for cloud-instances
Installed as default on most AWS Linux instances
Will automatically set the SSH key for the admin user if instance has
an associated SSH key
Cloudstack-guest-set-password
Will reset/set the admin account password
CloudStack Specific Optimizations
19. www.ShapeBlue.com @shapeblue
Shutdown the Instance
Create template from the instance > Volumes > Root
Volume tab
Set the template name and description
CentOS 6.5 Minimal (64bit)
CentOS 6.5 Minimal (32bit)
Enable password and dynamic scaling options
Register CentOS Template
21. www.ShapeBlue.com @shapeblue
Create a new instance from the template
Mark your template as public
Only admin can mark a template as public
Create templates for other hypervisors and architectures
VMware, KVM, Xen
Download more ISOs and create templates
Ubuntu
Debian
FreeBSD
Windows
Automate with Puppet / Chef / Vagrant / Ansible
Next Steps
22. www.ShapeBlue.com @shapeblue
Template creation in 3 easy steps
Register ISO
Create Instance from ISO
Customize and Optimize Instance
Register Root Volume as Template
Repeat process for every
OS
Hypervisor Type
Architecture
Root Volume Size
Recap
Note: If you cant find the exact minor version from the OS drop down list, choose the closest OS type. In this case its 6.4
I usually specify the exact name of the ISO for the name and description fields
I usually use 512MB 1vCPU offering. The data disk is effectively the “root” disk for your template. Choose its size wisely as CloudStack currently does not offer an easy way to resize your root fs
Be sure to customize the OS settings like Timezone, language, disk partitioning, root password etc. In the text installer, its no longer possible to configure network settings in CentOS 6.x. This will be a post install manual task. Please set the default root passwd to something strong. Minimal installer wont allow for package selection.
Do the detach ISO quickly so as to prevent the ISO installer from starting once again.
Networking: Remove any MAC IDs
SSHd would now be runningThe hostname would now match the name you specified while launching the instanceThe IP address of eth0 would match the IP address listed in the NIC details page for the instance
The tools package can be installed after attaching the tools ISOTraceroute is a good tool to install by default
If present, /etc/udev/rules.d/70-persistent-net.ruleswill stop the network from working correctly if the MAC address changes.
Adding a timestamp might be a good idea
You might also wish to create templates with different root disk sizes as well.