Create custom base images for VM app catalog
This document includes general guidelines for creating custom VM base image for the future use in Warren cloud platform.
Have a look at VM images for more information about basic configuration of any image for Warren platform.
Recommended tool for building images is packer.
Basic requirements for image:
packages installed:
install all the services needed (Wordpress, Drupal, mysql...) for the custom base image
configuration:
must be able to find cloud-init configuration source, e.g. 169.254.169.254, see below for an example
built base image file type:
image file types must be in supported qemu-img formats
One example workflow for creating custom VM image for the warren.io platform
Prepare your computer for building custom images, which will be future base images for the coming App Catalog
Get base image from trusted location, better to use server images for smaller size
From the disk image, create new VM in virtual-machine-manager
When using cloud image, new machine also needs cloud-init configuration info attached to the VM
on local machine install cloud-utils
make configuration file for VM boot
example:
cloud-config.txt
#cloud-config password: Password1 chpasswd: { expire: False } ssh_pwauth: True hostname: proxy1
convert previously made conf into *.iso file
example:
sudo cloud-localds cloud-config.iso ./cloud-config.txt
attach previously made cloud config image as IO/CD-rom device to the VM
boot up the VM to install desired applications and make initial configuration
Login to previously made VM
it is more comfortable to make actions on shell through ssh
Here is one example how to install WordPress on Ubuntu
there is still a lot of trial & error involved in the whole process
Install
qemu-guest-agent
. Example for Ubuntu:sudo apt update && sudo apt install qemu-guest-agent
For Ubuntu and possibly other distros, it is required to use a specific cloud-init configuration.
File location:/etc/cloud/cloud.cfg.d/00-ec2.cfg
File contents:/etc/cloud/cloud.cfg.d/00-ec2.cfg
datasource: Ec2: metadata_urls: [ '169.254.169.254' ] strict_id: false
Example command for creating the file, make sure escaped characters do not go missing if copy-pasting!
Enable IPv6 configuration.
Some OS distributions do not enable IPv6 networking out-of-the box, but this can be directed by cloud-init as well, similar to previous step. If the OS enables ipv6 (with dhcp) by default, then this step can be omitted. If unsure, it is safe to add this configuration anyway. See https://warrenio.atlassian.net/wiki/spaces/WAR/pages/12943916/Adding+vm+images#CentOS-and-IPv6 for more info about CentOS.
Add file/etc/cloud/cloud.cfg.d/99-custom-networking.cfg
:Or as one-liner
Clean the image, some cleanup can be done inside the running VM.
After stopping the VM, usevirt-sysprep
to delete existing users and their history from the image. Here wordpress_5.5 is the disk image file name.Next step is to put it up on warren.io platform and validate this VM image.