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:

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:

One example workflow for creating custom VM image for the warren.io platform

  1. Prepare your computer for building custom images, which will be future base images for the coming App Catalog

    1. install libvirt

    2. install qemu

    3. install cloud-init

    4. for GUI install virtual-machine-manager

  2. Get base image from trusted location, better to use server images for smaller size

    1. https://cloud-images.ubuntu.com

    2. https://cloud.debian.org/images/cloud/

    3. ...

  3. From the disk image, create new VM in virtual-machine-manager

    1. When using cloud image, new machine also needs cloud-init configuration info attached to the VM

      1. on local machine install cloud-utils

      2. make configuration file for VM boot

        • example: cloud-config.txt

          #cloud-config password: Password1 chpasswd: { expire: False } ssh_pwauth: True hostname: proxy1
      3. convert previously made conf into *.iso file

      4. example: sudo cloud-localds cloud-config.iso ./cloud-config.txt

  4. attach previously made cloud config image as IO/CD-rom device to the VM

  5. boot up the VM to install desired applications and make initial configuration

    1. Login to previously made VM

    2. it is more comfortable to make actions on shell through ssh

    3. Here is one example how to install WordPress on Ubuntu

      1. there is still a lot of trial & error involved in the whole process

    4. Install qemu-guest-agent. Example for Ubuntu:

      sudo apt update && sudo apt install qemu-guest-agent

       

    5. 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!

       

    6. 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

  6. Clean the image, some cleanup can be done inside the running VM.
    After stopping the VM, use virt-sysprep to delete existing users and their history from the image. Here wordpress_5.5 is the disk image file name.



  7. Next step is to put it up on warren.io platform and validate this VM image.