How To run CentOS 8 Instance on OpenStack

Posted on 136 views

How to add CentOS 8 cloud / KVM image to OpenStack?, How to run CentOS 8 instance/VM on OpenStack?. Openstack Glance service 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. In this guide we will upload CentOS 8 KVM Cloud image to Openstack Glance service.

For RHEL 8: How To Add RHEL 8 qcow2 Image To OpenStack Glance

The Vagrant and Cloud images for CentOS 8 were released when CentOS Linux 8 (1911) was made available for the general public. This release is derived from Red Hat Enterprise Linux 8.1 Source Code. The Cloud images are available at cloud.centos.org , for both CentOS 8 and CentOS 8 Stream.

The OpenStack Glance has support for the following image formats:

  • raw (unstructured format)
  • qcow2 (Qemu/KVM, supports Copy on Write)
  • iso (archive format for optical discs; for example, CD)
  • vhd (Hyper-V, common for virtual machine monitors from VMware, Xen, Microsoft, VirtualBox, and others)
  • vdi (Qemu/VirtualBox)
  • vmdk (VMware)
  • bare (no metadata is included)
  • aki/ami/ari (Amazon kernel, ramdisk, or machine image)
  • e.t.c.

Upload CentOS 8 Cloud Image to OpenStack Glance

Install wget for downloading the cloud image:

--- Debian / Ubuntu ---
$ sudo apt install -y wget

--- CentOS / Fedora ---
$ sudo yum -y install wget
$ sudo dnf -y install wget

Download the latest Cloud image from cloud.centos.org.

--- CentOS 8 Linux x86_64 ---
wget https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.1.1911-20200113.3.x86_64.qcow2

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

You can further customize qcow2 image using our guide as reference before uploading it.

How To Customize Qcow2/Raw Linux OS disk image with virt-customize

Then source openstack environment.

source ~/.keystonerc

And upload CentOS 8 Cloud Images to OpenStack Glance.

--- CentOS 8 Linux x86_64 ---
$ openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file CentOS-8-GenericCloud-8.1.1911-20200113.3.x86_64.qcow2 \
    CentOS-8

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

If you don’t have openstack CLI, check: How To Install and Configure OpenStack Client on Linux

Confirm if the images are available in Glance:

$ openstack image list | grep CentOS-8
| adbe1f0c-665e-481a-b689-e32414339415 | CentOS-8        | active |
| 035221af-97e4-4801-b171-fc1b6fc2245d | CentOS-8-Stream | active |

You can also use the Horizon Web interface to upload the images – Navigate to Project > Compute > Images > CREATE IMAGE

upload-centos-8-image-openstack

Provide image name, description, browse and select image from source, choose image visibility click on “Create Image” button.

Once the image is uploaded, the details are available under the Images section.

upload-centos-8-image-openstack-02-1024x523

You can now launch an instance from the uploaded image. See below example:

$ openstack server create \
 --image CentOS-8 \
 --key-name jmutai \
 --flavor m1.small \
 --security-group  7fffea2a-b756-473a-a13a-219dd0f1913a  \
 --network private  \
 mycentos8

Confirm server creation:

$ openstack server list 
+--------------------------------------+-------------------+---------+-----------------------------------+-----------+----------+
| ID                                   | Name              | Status  | Networks                          | Image     | Flavor   |
+--------------------------------------+-------------------+---------+-----------------------------------+-----------+----------+
| 9e1e1b14-db2c-405e-9361-6b1b08c707b8 | mycentos8         | ACTIVE  | private=10.10.1.138               | CentOS-8  | m1.small |
+--------------------------------------+-------------------+---------+-----------------------------------+-----------+----------+

Let’s test if we can ssh to the server created.

$ ssh [email protected]
Warning: Permanently added '10.10.1.138' (ECDSA) to the list of known hosts.
Enter passphrase for key '/home/jmutai/.ssh/id_rsa': 
Activate the web console with: systemctl enable --now cockpit.socket

[[email protected] ~]$ cat /etc/os-release 
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"

[[email protected] ~]$ exit
logout
Connection to 10.10.1.138 closed.

We can confirm we’re logged into CentOS 8 instance by checking the /etc/os-release contents.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.