[OpenStack] OpenStack Essex - Glance - Image Management

Introduction

There are several pre-built images for OpenStack available from various sources. You can download such images and use them to get familiar with OpenStack.

For any production deployment, you may like to have the ability to bundle custom images, with a custom set of applications or configuration. This chapter will guide you through the process of creating Linux images of popular distributions from scratch. We have also covered an approach to bundling Windows images.

There are some minor differences in the way you would bundle a Linux image, based on the distribution. Ubuntu makes it very easy by providing cloud-init package, which can be used to take care of the instance configuration at the time of launch. cloud-init handles importing ssh keys for password-less login, setting host name etc. The instance acquires the instance specific configuration from Nova-compute by connecting to a meta data interface running on 169.254.169.254.

While creating the image of a distro that does not have cloud-init or an equivalent package, you may need to take care of importing the keys etc. by running a set of commands at boot time from rc.local.

The process used for creating the Linux images of different distributions is largely the same with a few minor differences, which is explained below.

In all the cases, the documentation below assumes that you have a working KVM installation to use for creating the images. We are using the machine called 'client1' as explained in the chapter on "Installation and Configuration" for this purpose.

The approach explained below will generate disk images that represent a disk without any partitions.

Creating a Linux Image

The first step would be to create an image on Client1. This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need.

kvm-img create -f qcow2 server.img 5G

 OS Installation

Download the iso file of the Linux distribution you want to install in the image. For Ubuntu, you can download the iso from http://releases.ubuntu.com using 'wget' or with the help of a browser

Boot a KVM instance with the OS installer ISO in the virtual CD-ROM. This will start the installation process. The command below also sets up a VNC display at port 0

 
sudo kvm -m 256 -cdrom ubuntu-12.04-server-amd64.iso -drive file=server.img,if=virtio,index=0 -boot d -net nic -net user -nographic  -vnc :0

Connect to the VM through VNC (use display number :0) and finish the installation.

For Example, where 10.10.10.4 is the IP address of client1:

 
vncviewer 10.10.10.4 :0

During creation of Linux images , create a single ext4 partition mounted on a swap partition.

After finishing the installation, relaunch the VM by executing the following command.

 
sudo kvm -m 256 -drive file=server.img,if=virtio,index=0 -boot c -net nic -net user -nographic -vnc :0

At this point, you can add all the packages you want to have installed, update the installation, add users and make any configuration changes you want in your image.

 Uploading the Linux image

Upload the image

glance add name="<Image name>" is_public=true container_format=ovf disk_format=qcow2 < <filename>.img



Creating a Windows Image

The first step would be to create an image on Client1, this will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need.

 
kvm-img create -f qcow2 windowsserver.img 20G

 OS Installation

OpenStack presents the disk using a virtio interface while launching the instance. Hence the OS needs to have drivers for virtio. By default, the Windows Server 2008 ISO does not have the drivers for virtio. Download the iso image containing virtio drivers from the following location http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin and attach it during the installation

Start the installation by executing:

sudo kvm -m 1024 -cdrom windows2008.iso -drive file=windowsserver1.img,if=virtio -boot d -drive file=virtio-win-0.1-22.iso,index=3,media=cdrom  -device virtio-net-pci -net nic -net user -nographic -vnc :5

When the installation prompts you to choose a hard disk device you won't see any devices available. Click on "Load drivers" at the bottom left and load the drivers by browsing the secondary CDROM in which the virtio driver disk is loaded

After the installation is over, boot into it once and install any additional applications you need to install and make any configuration changes you need to make. Also ensure that RDP is enabled as that would be the only way you can connect to a running instance of Windows. Windows firewall needs to be configured to allow incoming ICMP and RDP connections.

Uploading the Windows image

Shut-down the VM and upload the image to OpenStack

 
glance add name="windows" is_public=true container_format=ovf disk_format=qcow2 < windowsserver.img

转载于:https://www.cnblogs.com/licheng/archive/2012/06/04/2534720.html

猜你喜欢

转载自blog.csdn.net/weixin_34014277/article/details/92627823
今日推荐