In this tutorial, we’re going to look at how to add VM images to Openstack Glance image service. I assume you already have a running Openstack setup, and glance service runs on the controller node.

What is Openstack image service?

Openstack glance enables users to discover, register, and retrieve virtual machine images. The default location these images are stored is /var/lib/glance/images/ with its backend being a file.

Openstack image service also offers a REST API that enables you to query virtual machine image metadata and retrieve an actual image. You can store virtual machine images made available through the Image service in a variety of locations, from simple file systems to object-storage systems like OpenStack Object Storage.

Obtaining Glance images?

The simplest way to obtain a virtual machine image that works with OpenStack is to download one that someone else has already created. Most of the images contain the cloud-init package to support the SSH key pair and user data injection.

I’ll show you how to add images for various operating systems by downloading what other people already made. Of course, you can create your own images, but it is faster to obtain ready-made images.

Default Login credentials

Below are the default login usernames for instances created from the images added shortly.

  • Debian: debian
  • Fedora: fedora
  • Ubuntu: ubuntu
  • RHEL: cloud-user
  • AlmaLinux: almalinux
  • Rocky Linux: rocky
  • CentOS Stream 8: centos
  • CentOS Stream 9: cloud-user
  • CoreOS: core
  • Arch Linux: arch
  • Gentoo: gentoo
  • OpenSUSE: root
  • Fedora CoreOS: core
  • Cirros: username: cirros, Password: cubswin:)
  • FreeBSD: freebsd
  • OpenBSD: openbsd
  • NetBSD: netbsd

Examples:

Adding Cirros cloud image to OpenStack

VERSION=$(curl -s http://download.cirros-cloud.net/version/released)
wget http://download.cirros-cloud.net/$VERSION/cirros-$VERSION-x86_64-disk.img

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file cirros-$VERSION-x86_64-disk.img \
    Cirros

Adding Rocky Linux cloud image to OpenStack

Rocky Linux 9:

wget http://download.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud.latest.x86_64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file Rocky-9-GenericCloud.latest.x86_64.qcow2 \
    Rocky-Linux-9

Rocky Linux 8

wget https://download.rockylinux.org/pub/rocky/8/images/Rocky-8-GenericCloud.latest.x86_64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file Rocky-8-GenericCloud.latest.x86_64.qcow2 \
    Rocky-Linux-8

Adding AlmaLinux cloud image to OpenStack

Use the commands below:

AlmaLinux 9

wget https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file AlmaLinux-9-GenericCloud-latest.x86_64.qcow2 \
    AlmaLinux-9

AlmaLinux 8

wget https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file AlmaLinux-8-GenericCloud-latest.x86_64.qcow2 \
    AlmaLinux-8

Adding Fedora Cloud Image to Openstack

Check latest from Fedora image downloads page.

wget https://download.fedoraproject.org/pub/fedora/linux/releases/41/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-41-1.4.x86_64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file Fedora-Cloud-Base-Generic-41-1.4.x86_64.qcow2 \
    Fedora-41

Adding CentOS Image to Openstack Glance

CentOS Stream 9:

wget https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file  CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2 \
    CentOS-Stream-9

CentOS Stream 8:

wget https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2

openstack image create \
--container-format bare \
--disk-format qcow2 \
--file CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2 \
CentOS-Stream-8

CentOS 7:

wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file CentOS-7-x86_64-GenericCloud.qcow2 \
    CentOS-7

Adding Ubuntu Cloud Image to Openstack

Adding Ubuntu based images:

Ubuntu 24.04:

wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img

openstack image create \
     --container-format bare \
     --disk-format qcow2 \
     --file noble-server-cloudimg-amd64.img \
      Ubuntu-24.04

Ubuntu 22.04:

wget http://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file jammy-server-cloudimg-amd64.img \
    Ubuntu-22.04

Ubuntu 20.04:

wget http://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file focal-server-cloudimg-amd64.img \
    Ubuntu-20.04

Ubuntu 18.04:

wget http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file bionic-server-cloudimg-amd64.img \
    Ubuntu-18.04

Adding Debian Cloud Image to Openstack

Debian 12 (Bookworm)

wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --property hw_disk_bus=scsi \
    --property hw_scsi_model=virtio-scsi \
    --property os_type=linux \
    --property os_distro=debian \
    --property os_admin_user=debian \
    --public \
    --file debian-12-generic-amd64.qcow2 \
    Debian-12

Debian 11 (Bullseye):

wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --property hw_disk_bus=scsi \
    --property hw_scsi_model=virtio-scsi \
    --property os_type=linux \
    --property os_distro=debian \
    --property os_admin_user=debian \
    --public \
    --file debian-11-generic-amd64.qcow2 \
    Debian-11

Debian 10 (Buster):

wget https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-amd64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --property hw_disk_bus=scsi \
    --property hw_scsi_model=virtio-scsi \
    --property os_type=linux \
    --property os_distro=debian \
    --property os_admin_user=debian \
    --public \
    --file debian-10-generic-amd64.qcow2 \
    Debian-10

Debian 9 (Stretch):

wget http://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --property hw_disk_bus=scsi \
    --property hw_scsi_model=virtio-scsi \
    --property os_type=linux \
    --property os_distro=debian \
    --property os_admin_user=debian \
    --public \
    --file debian-9-openstack-amd64.qcow2 \
    Debian-9

Adding Arch Linux Cloud Image to Openstack

wget https://linuximages.de/openstack/arch/arch-openstack-LATEST-image-bootstrap.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file arch-openstack-LATEST-image-bootstrap.qcow2 \
    Arch-Linux

Adding Fedora CoreOS Cloud Image

Download Fedora CoreOS image:

RELEASE=40.20240519.3.0
wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/$RELEASE/x86_64/fedora-coreos-$RELEASE-openstack.x86_64.qcow2.xz

Extract the image:

unxz fedora-coreos-$RELEASE-openstack.x86_64.qcow2.xz

Upload extracted image:

openstack image create Fedora-CoreOS \
                       --public \
                       --disk-format=qcow2 \
                       --container-format=bare \
                       --property os_distro=fedora-coreos \
                       --file=fedora-coreos-$RELEASE-openstack.x86_64.qcow2

Add Flatcar Container Linux to OpenStack

You can check OS releases page for specific versions. We recommend using the Stable channel for production clusters.

wget https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_openstack_image.img.bz2
bunzip2 flatcar_production_openstack_image.img.bz2

Once the download completes, add the Flatcar Container Linux image into Glance:

openstack image create Flatcar-Container-Linux \
                       --public \
                       --container-format bare \
                       --disk-format qcow2 \
                       --file flatcar_production_openstack_image.img

Adding FreeBSD / OpenBSD / NetBSD Cloud Images

We will use the unofficial OpenStack images for these BSD systems available on BSD-Cloud-Image.org. Visit the page and get the latest images.

  • FreeBSD
# Download FreeBSD 14 - using UFS
wget https://object-storage.public.mtl1.vexxhost.net/swift/v1/1dbafeefbd4f4c80864414a441e72dd2/bsd-cloud-image.org/images/freebsd/14.0/2024-05-04/ufs/freebsd-14.0-ufs-2024-05-04.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file freebsd-14.0-ufs-2024-05-04.qcow2 \
    freebsd-14.0-ufs


# Downloading FreeBSD 14 - using ZFS
wget https://object-storage.public.mtl1.vexxhost.net/swift/v1/1dbafeefbd4f4c80864414a441e72dd2/bsd-cloud-image.org/images/freebsd/14.0/2024-05-06/zfs/freebsd-14.0-zfs-2024-05-06.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file freebsd-14.0-zfs-2024-05-04.qcow2 \
    freebsd-14.0-zfs
  • NetBSD
wget https://object-storage.public.mtl1.vexxhost.net/swift/v1/1dbafeefbd4f4c80864414a441e72dd2/bsd-cloud-image.org/images/netbsd/9.3/2023-04-23/ufs/netbsd-9.3-2023-04-23.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file netbsd-9.3-2023-04-23.qcow2 \
    netbsd-9.3
  • OpenBSD
wget https://github.com/hcartiaux/openbsd-cloud-image/releases/download/v7.5_2024-05-13-15-25/openbsd-min.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file openbsd-min.qcow2 \
    openbsd-7.5

Adding Gentoo Cloud Image to Openstack

wget https://linuximages.de/openstack/gentoo/gentoo-openstack-LATEST-image-bootstrap.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file gentoo-openstack-LATEST-image-bootstrap.qcow2 \
    Gentoo

Adding SUSE Enterprise Linux (SLES)

Visit official SLES Downloads page page to download QCOW2 image to be used on OpenStack.

$ ls SLES15-SP5-Minimal-VM.x86_64-Cloud-GM.qcow2
SLES15-SP5-Minimal-VM.x86_64-Cloud-GM.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file SLES15-SP5-Minimal-VM.x86_64-Cloud-GM.qcow2 \
    SLES15-SP5
wget https://download.opensuse.org/repositories/SUSE:/Templates:/Images:/SLE-15/images/SLES15-JeOS.x86_64-15.0-OpenStack-Cloud-Build3.59.qcow2

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file SLES15-JeOS.x86_64-15.0-OpenStack-Cloud-Build3.59.qcow2 \
    SLES15-JeOS

Adding Windows Server 2012 image

Download image from https://cloudbase.it/windows-cloud-images/#download

gunzip -cd windows_server_2012_r2_standard_eval_kvm_20170321.qcow2.gz

openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file windows_server_2012_r2_standard_eval_kvm_20170321.qcow2 \
    Windows-Server-2012-R2-Std

Setting image options options

Now let’s set all images to be publicly visible and protect them from accidental deletion.

IMAGE_IDS=`openstack image list | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' -o`
for i in ${IMAGE_IDS[@]}; do
    openstack image set --public $i
    openstack image set --protected $i
done

Confirm from Horizon Dashboard by going to Project > Compute > Images. You should notice Protected flag is set to yes for all images and Visibility set to Public as well.

adding images to openstack glance

Next is addition of OS flavors: How To Add Computer Flavors To Openstack from CLI

Reference:

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here