2021 Call for Code Awards: Live from New York, with SNL’s Colin Jost! Learn more

Creating OVA images using a CentOS instance in IBM Power Systems Virtual Servers

Introduction

This tutorial is an enhancement of the previous tutorial for creating and uploading OVA images to IBM Power Systems 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 Systems 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.1.8(1)-release)
  • Microsoft Windows10 with Windows Subsystem for Linux (WSL)
  • Linux x86_64 system (GNU bash, version 4.3.48(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 2.5 to 3 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.

  1. 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)
    
  2. Run the convert-upload-images-powervs script.

    • Run the script using the stand-alone execution method.

      1. Download the script.

        curl -O -fsSL https://raw.githubusercontent.com/ppc64le-cloud/pvsadm/master/samples/convert-upload-images-powervs/convert-upload-images-powervs
        
      2. Provide execute permission to run script.

        chmod +x ./convert-upload-images-powervs
        
      3. Run 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.1 [ --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/4e/xxxxxx/rhel-8.4-ppc64le-kvm.qcow2?user\=xxxxxxxxxxx&_auth_\=xxxxxxx”  --rhcos-url  “https://mirror.openshift.com/pub/openshift-v4/ppc64le/dependencies/rhcos/4.7/4.7.0/rhcos-4.7.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.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/4e/xxxxxx/rhel-8.4-ppc64le-kvm.qcow2?user\=xxxxxxxxxxx&_auth_\=xxxxxxx”  --rhcos-url  “https://mirror.openshift.com/pub/openshift-v4/ppc64le/dependencies/rhcos/4.8/latest/rhcos-4.8.2-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)

Sample output

[setup] Installing dependency packages and tools
[setup_tools] Verifying the latest packages and tools
[setup_ibmcloudcli] Installing the latest version of IBM-Cloud CLI...
Attempt: 1/5
[...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
[create_cos_bucket] Creating a new cos instance and bucket my-test-bucket-2001(if not present)
[...snip...]
 successfully in 0.464415 seconds to location https://s3.us-south.cloud-object-storage.appdomain.cloud/my-test-bucket-2001/demo.6jfQ5xfoZK
[create_cos_bucket] SUCCESS: Creating new bucket successful
[...snip...]
Attempt: 1/5
[convert_image_remote] SUCCESS: Converting rhel-84-03042021 completed
[convert_image_remote] Converting rhel-84-03042021 image to OVA completed in: 0hrs 8min 46sec
[upload_image_remote] Uploading image /tmp/tmp.0Pvluq3RKo/rhel-84-03042021.ova.gz to the cos bucket my-test-bucket-2001
Attempt: 1/5
[upload_image_remote] WARN: /tmp/tmp.0Pvluq3RKo/rhel-84-03042021.ova.gz object already exists in the my-test-bucket-2001 bucket. Skipping upload
[upload_image_remote] Uploading /tmp/tmp.0Pvluq3RKo/rhel-84-03042021.ova.gz image to my-test-bucket-2001 completed in: 0hrs 0min 13sec
[import_image_remote] Importing rhel-84-03042021.ova.gz to my-powervs-service
Attempt: 1/5
[import_image_remote] SUCCESS: Importing rhel-84-03042021.ova.gz to my-powervs-service completed
[import_image_remote] Importing rhel-84-03042021.ova.gz image to my-powervs-service completed in: 0hrs 26min 18sec
[convert_image_remote] Converting rhel/rhcos/centos images from qcow2 to ova
[...snip...]
[destroy] Running terraform destroy... please wait
[is_terraform_running] WARN: Last run was less than a min ago... please wait
Attempt: 1/5
[retry_terraform] Completed running the terraform command.
[destroy] SUCCESS: Done! destroy command completed
Thursday March 04 2021 03:27:34 PM 
╭─pvsadm/samples/convert-upload-images-powervs

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.