You are here

architecting your data center (version 2) - part 2 - the vm template

welcome back, in this series of articles i am documenting my steps as i build out an infrastructure to support an openstack cloud.

previously, i set up a kvm server. in this article i will briefly describe the steps i took to configure a vm to be a template to clone from

the VM was of course, installed from the centos 7 iso. i used the minimal server configuration. i also made sure that my root partition was on lvm, which is on vda. vda was given 10GB. i like lvm. if i run out of space, just add another virtual disk and stick it into the root disk lvm.

once the os is installed, we want to add some packages

yum -y install screen vim ntp bash-completeion deltarpm ipa-client 

the most important program there is deltarpm. it is used by yum-presto which in centos7 is now a default plugin that is installed with yum. it is also the plugin that interfaces with deltarpm to install .. delta rpms. delta rpms are as the names indicates rpms of the changes between 2 versions of rpms. this saves bandwidth as you wont have to download the entire rpm to complete an update of an rpm package

once those packages are installed, we can configure ntp

chkconfig ntpd on
ntpdate -b
service ntpd restart
sleep 1m #give ntp to sync
ntpq -p

and then we can update the entire system

yum -y update

now a couple of things to note before we go on.

i gave this VM an ip high up in the range. i gave it i decided to give it an ip outside the range of floating ips i was going to use coz i didnt want to have an ip conflict. i also decided to give it an IP and let it keep that IP coz i decided that i needed to update the "template" every so often.

i am thinking of a cron job on the kvm server that once a month will power up the vm, run a yum update on it and then shut it down. this will help decrease bandwidth usage and save me a few minutes on updates.

next, my kvm server is not my workstation, its not even in my office. so while i can run virt-manager or even virt-viewer to get to the console of the virtual machine, why do that when i can get to it via the command line. the command for that is

virsh console <instance_name>

however, the virtual machine must be prepared to do that and thats through editing /etc/default/grub and adding the following to the GRUB_CMDLINE_LINUX parameter

text console=tty0 console=ttyS0

and finally, you may have noticed that i installed ipa-client. this cloned virtual machine will eventually be registered with the freeipa server. it will also be registered with the spacewalk server too. but that is another article on another day.

and last but not the least, i copied the kvm server's public ssh keys onto the VM template machine. this way after cloning, the kvm server can _always_ login without password. and the command for that is, of course, run from the kvm server:

ssh-copy-id root@template

if you got any ideas on how i can improve my vm template, let me know in the comments below.