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
- CentOS: centos
- CoreOS: core
- Arch Linux: arch
- Gentoo: gentoo
- OpenSUSE: root
- Fedora CoreOS: core
- Cirros: username: cirros, Password: cubswin:)
Examples:
1. Adding Cirros Cloud image to Glance
wget http://download.cirros-cloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img
openstack image create \
--container-format bare \
--disk-format qcow2 \
--file cirros-0.5.2-x86_64-disk.img \
Cirros-0.5.2
2. Adding Fedora Cloud Image to Openstack
wget http://fedora.mirror.liquidtelecom.com/fedora/linux/releases/35/Cloud/x86_64/images/Fedora-Cloud-Base-35-1.2.x86_64.qcow2
openstack image create \
--container-format bare \
--disk-format qcow2 \
--file Fedora-Cloud-Base-35-1.2.x86_64.qcow2 \
Fedora-35
3. Adding CentOS Cloud Image to Openstack
CentOS Stream 8:
wget https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20210603.0.x86_64.qcow2
openstack image create \
--container-format bare \
--disk-format qcow2 \
--file CentOS-Stream-GenericCloud-8-20210603.0.x86_64.qcow2 \
CentOS-Stream-8
CentOS 8:
wget https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2
openstack image create \
--container-format bare \
--disk-format qcow2 \
--file CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2 \
CentOS-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
3. Adding Ubuntu Cloud Image to Openstack
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
4. Adding Debian Cloud Image to Openstack
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-10
5. Adding CoreOS Cloud Image to Openstack
wget https://stable.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2
#wget http://beta.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2
bunzip2 coreos_production_openstack_image.img.bz2
openstack image create \
--container-format bare \
--disk-format qcow2 \
--property os_distro=coreos \
--file coreos_production_openstack_image.img \
CoreOS
6. 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
7. 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
8. Adding Fedora CoreOS Image to OpenStack
Download Fedora CoreOS image:
wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/35.20211203.3.0/x86_64/fedora-coreos-35.20211203.3.0-openstack.x86_64.qcow2.xz
Extract the image:
unxz fedora-coreos-35.20211203.3.0-openstack.x86_64.qcow2.xz
Upload extracted image:
openstack image create Fedora-CoreOS-35 \
--public \
--disk-format=qcow2 \
--container-format=bare \
--property os_distro=fedora-coreos \
--file=fedora-coreos-35.20211203.3.0-openstack.x86_64.qcow2
9. 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
Check list of images available in Glance.
$ openstack image list
+--------------------------------------+---------------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------------+--------+
| 0850ee38-1bdf-4379-9c69-0cf73e8b7c65 | Arch-Linux-x86_64 | active |
| e98445b6-f14f-488c-a18a-1f66c6de15c7 | CentOS-7-x86_64 | active |
| 7b4b616e-71f3-4419-9777-7aee66fad62c | Cirros-0.4.0-x86_64 | active |
| 98bbd9e6-abbc-45fa-ac95-b91b7b18ba0a | Debian-9-amd64 | active |
| 113b90b6-4e1e-4715-b9ab-456c191a82b3 | Fedora-30-x86_64 | active |
| 06c17e8a-0d4c-428a-89b5-b0eb2489f403 | Ubuntu-16.04-x86_64 | active |
+--------------------------------------+---------------------+--------+
10. Add FreeBSD images
For FreeBSD use the following commands:
# FreeBSD 13
wget https://download.freebsd.org/ftp/releases/VM-IMAGES/13.0-RELEASE/amd64/Latest/FreeBSD-13.0-RELEASE-amd64.qcow2.xz
unxz FreeBSD-13.0-RELEASE-amd64.qcow2.xz
openstack image create \
--container-format bare \
--disk-format qcow2 \
--file FreeBSD-13.0-RELEASE-amd64.qcow2 \
FreeBSD-13
# FreeBSD 12
wget https://download.freebsd.org/ftp/releases/VM-IMAGES/12.2-RELEASE/amd64/Latest/FreeBSD-12.2-RELEASE-amd64.qcow2.xz
unxz FreeBSD-12.2-RELEASE-amd64.qcow2.xz
openstack image create \
--container-format bare \
--disk-format qcow2 \
--file FreeBSD-12.2-RELEASE-amd64.qcow2 \
FreeBSD-12
11. AlmaLinux 8
Use the commands below:
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
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.
Next is addition of OS flavors: How To Add Computer Flavors To Openstack from CLI
Reference: