About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Tutorial
Creating OVA images using a CentOS instance in IBM Power Virtual Servers
Automated RHEL and RHCOS OVA image creation using Power Virtual Server
Introduction
This tutorial is an enhancement of the previous tutorial for creating and uploading OVA images to IBM Power Virtual Server. It provides a completely automated way by using a script for creating and uploading Red Hat Enterprise Linux (RHEL) and Red Hat Enterprise Linux CoreOS (RHCOS) OVA images. This script creates its own CentOS virtual machine (VM) in Power Virtual Server to perform all the conversion tasks. This script uses the pvsadm tool to manage the image conversion and upload tasks. In this tutorial, we describe two ways of running the convert-upload-images-powervs script:
- Run using the stand-alone execution method
- Run using a container image
Workflow
The workflow of the script for creating and uploading images includes:
- Creating a CentOS instance using the default CentOS image present in Power Virtual Server with terraform code.
- Converting the given RHEL and RHCOS images from the created CentOS instance using the pvsadm tool.
- Uploading and importing the RHEL and RHCOS OVA images from the CentOS instance using the pvsadm tool.
Prerequisites
If you prefer the stand-alone execution method, then ensure that the following prerequisites are met for your operating system:
- Mac OS X (Bash version:5.2.15(1)-release)
- Microsoft Windows10 with Windows Subsystem for Linux (WSL)
- Linux x86_64 system (GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu))
The prerequisites for running the automation script include:
- Access to any of the environments supported (mentioned in previous section) with internet connectivity.
- Docker or any other container runtime if using the container image
- IBM cloud API key to login to the service instance
- A valid Red Hat subscription (for RHEL image)
Estimated time
It requires approximately 45 minutes to 1.5 hours for creating OVA images and uploading them to an IBM Power Virtual Server service using the automated script.
Steps
This section provides the steps for using the script to convert and upload an OVA image into the IBM Cloud Virtual Server instance.
Export the required keys and RHEL credentials for creating and uploading the OVA images.
export IBMCLOUD_API_KEY="<ibm cloud api key>" export RHEL_SUBSCRIPTION_USERNAME="<redhat subscription username>" (only if you are creating rhel image) export RHEL_SUBSCRIPTION_PASSWORD="<redhat subscription password>" (only if you are creating rhel image) export RHEL_ROOT_PASSWORD="<rhel root password>" (if the user doesn’t set this variable, the script will generate a password)Run the convert-upload-images-powervs script.
Run the script using the stand-alone execution method.
Download the script.
curl -O -fsSL https://raw.githubusercontent.com/ppc64le-cloud/pvsadm/master/samples/convert-upload-images-powervs/convert-upload-images-powervsProvide execute permission to run script.
chmod +x ./convert-upload-images-powervsRun the script.
./convert-upload-images-powervs [ --rhel-url <url> | --rhcos-url <url> ] --service-name <service name> --region <bucket region> --cos-bucket <bucket name> --cos-resource-group <resource group> –-cos-instance-name <cos instance name>
Run the script using a container image.
docker run -it -e IBMCLOUD_API_KEY=$IBMCLOUD_API_KEY -e RHEL_SUBSCRIPTION_USERNAME=$RHEL_SUBSCRIPTION_USERNAME -e RHEL_SUBSCRIPTION_PASSWORD=$RHEL_SUBSCRIPTION_PASSWORD -e RHEL_ROOT_PASSWORD=$RHEL_ROOT_PASSWORD quay.io/powercloud/image-upload:0.3 [ --rhel-url <url> | --rhcos-url <url> ] --service-name <service name> --region <bucket region> --cos-bucket <bucket name> --cos-resource-group <resource group> --cos-instance-name <cos instance name>
Use the following URLs for RHEL, and RHCOS Qcow2 images.
Note: You need a valid Red Hat subscription to access the RHEL images.
\
Example usage
Using the stand-alone execution method
./convert-upload-images-powervs --service-name my-powervs-service --region us-south --cos-bucket my-cos-bucket --cos-resource-group my-resource-group –cos-instance-name my-instance --rhel-url “https://access.cdn.redhat.com/content/origin/files/sha256/1b/xxxxxx/rhel-8.8-ppc64le-kvm.qcow2?user\=xxxxxxxxxxx&_auth_\=xxxxxxx” --rhcos-url “https://mirror.openshift.com/pub/openshift-v4/ppc64le/dependencies/rhcos/4.13/4.13.0/rhcos-4.13.0-ppc64le-openstack.ppc64le.qcow2.gz”
Using a container image
docker run -it -e IBMCLOUD_API_KEY=$IBMCLOUD_API_KEY -e RHEL_SUBSCRIPTION_USERNAME=$RHEL_SUBSCRIPTION_USERNAME -e RHEL_SUBSCRIPTION_PASSWORD=$RHEL_SUBSCRIPTION_PASSWORD -e RHEL_ROOT_PASSWORD=$RHEL_ROOT_PASSWORD quay.io/powercloud/image-upload:0.30.1 --service-name my-powervs-service --region us-south --cos-bucket my-cos-bucket --cos-resource-group my-resource-group –cos-instance-name my-instance --rhel-url “https://access.cdn.redhat.com/content/origin/files/sha256/1b/xxxxxx/rhel-8.8-ppc64le-kvm.qcow2?user\=xxxxxxxxxxx&_auth_\=xxxxxxx” --rhcos-url “https://mirror.openshift.com/pub/openshift-v4/ppc64le/dependencies/rhcos/4.13/4.13.0/rhcos-4.13.0-ppc64le-openstack.ppc64le.qcow2.gz”
Where:
| Parameter | Description |
|---|---|
--service-name |
A list of Power Virtual Server service instances with comma separated (mandatory) |
--region |
Object store bucket region (mandatory) |
--cos-bucket |
Object store bucket name (mandatory) |
--cos-resource-group |
Cloud Object Storage resource group (mandatory) |
--cos-instance-name |
Cloud Object Storage instance name (mandatory) |
--rhel-url |
An URL pointing to the RHEL Qcow2 image (optional) |
--rhcos-url |
An URL pointing to the RHCOS Qcow2 image (optional) |
--skip-os-password |
Skip the root user password (optional) |
Sample output
[setup] Running setup command...
[setup_artifacts] Downloading code artifacts test in ./automation
Attempt: 1/5
[setup] SUCCESS: setup command completed!
[setup_ibmcloudcli] Installing the latest version of IBM-Cloud CLI...
[...snip...]
[variables] Trying to login with the provided IBMCLOUD_API_KEY...
Targeting service crn:v1:bluemix:public:power-iaas:tok04:a/65b64c1f1c29460e:e4bb3d9d-a37c-xxxx-yyyy-4537c0c8beb3::...
[variables] Gathering information from the selected Service Instance... Please wait
[variables] WARN: Using autogenerated rhel root password from environment variables, please export RHEL_ROOT_PASSWORD if you want to set your own
[variables] SUCCESS: variables command completed!
[create_cos_bucket] Creating a new cos instance and bucket my-test-bucket-2023(if not present)
[get_cos_service_id] get crn for cos instance
Attempt: 1/5
[create_cos_bucket] SUCCESS: Created new bucket my-test-bucket-2023 in cos instance my-instance
Attempt: 1/5
[...snip...]
[convert_image_remote] Converting rhel-88-07192023 from qcow2 to ova
Attempt: 1/5
[convert_image_remote] Autogenerated root password 7SEaILrBEz7JRYhx
[convert_image_remote] SUCCESS: Converting rhel-88-07192023 completed
[convert_image_remote] Converting rhel-88-07192023 image to OVA completed in: 0hrs 11min 51sec
[upload_image_remote] Uploading image /tmp/tmp.ApSdd1dVaM/rhel-88-07192023.ova.gz to the cos bucket my-test-bucket-2023
Attempt: 1/5
[upload_image_remote] SUCCESS: Uploading /tmp/tmp.ApSdd1dVaM/rhel-88-07192023.ova.gz to my-test-bucket-2023 completed
[upload_image_remote] Uploading /tmp/tmp.ApSdd1dVaM/rhel-88-07192023.ova.gz image to my-test-bucket-2023 completed in: 0hrs 6min 17sec
[import_image_remote] Importing rhel-88-07192023.ova.gz to my-powervs-service
Attempt: 1/5
[import_image_remote] SUCCESS: Importing rhel-88-07192023.ova.gz to my-powervs-service completed
[import_image_remote] Importing rhel-88-07192023.ova.gz image to my-powervs-service completed in: 0hrs 12min 30sec
[convert_image_remote] Converting rhcos-413-07192023 from qcow2 to ova
Attempt: 1/5
[...snip...]
[destroy] Running terraform destroy... please wait
[is_terraform_running] WARN: Last run was less than a min ago... please wait a minute
Attempt: 1/5
[retry_terraform] Completed running the terraform command.
[destroy] SUCCESS: Done! destroy command completed
[destroy_vm] VM Destroy completed in: 0hrs 10min 20sec
Note: You need to provide any or combination of --rhel-url, --rhcos-url URLs for image conversion and uploading to the Power Virtual Server service. If the RHEL URL pointing to access.cdn.redhat.com expires, just refresh the page to get the new URL.
Summary
In this tutorial, we have used an automated script for creating and uploading images in Power Virtual Server from a Centos VM. You are now all set for deploying an OpenShift cluster.