Preparing boot image (OVA) files for use by Red Hat OpenShift Container Platform clusters on IBM Power Systems Virtual Servers

This tutorial is part of the Learning path: Deploying Red Hat OpenShift Container Platform 4.x on IBM Power Systems Virtual Servers.

Introduction

A Red Hat® OpenShift® cluster in IBM® Power Systems™ Virtual Server requires two images:

  • The Red Hat Enterprise Linux (RHEL) 8.2 image – This is used by the bastion node
  • Red Hat Enterprise Linux CoreOS (RHCOS) image – This is used on the OpenShift cluster nodes

This tutorial shows how to create OVA formatted images for both RHEL and RHCOS, and upload them to IBM Cloud Object Storage (COS). You can then import these images as boot images in your IBM Power Systems Virtual Server service. Note that the image disk should be a minimum of 120 GB in size.

Prerequisites

Make sure that the following prerequisites are met before you begin creating the OVA images:

  • Access to shell on IBM Power® logical partition (LPAR) running RHEL 8 or CentOS 8 with internet connectivity and the following required packages:
    • dnf install python3 qemu-img
    • pip3 install jinja2 boto3
    • pip3 install -U PyYAML (must be version 5.1 or later)
  • The LPAR should have a minimum of 200 GB free space.

Estimated time

It would take approximately 1 to 2 hours to create and upload the OVA images to IBM Cloud Object Storage, depending on the size of images and the CPU speed of the Power LPAR.

Steps

Perform the following steps to create the OVA images:

Create OVA images

  1. Download RHEL and RHCOS images on the IBM Power LPAR.

  2. In a working directory on the Power LPAR, run the following commands to download
    the code:
    $ git clone https://github.com/ocp-power-automation/infra.git
    $ cd infra/scripts/images

  3. Understand the options available for the convert_qcow2_ova.py script.
    $ python3 convert_qcow2_ova.py -h

    Note that the following options are available:
    -u: URL or absolute local file path to the .gz image
    -s: Size (in GB) of the resultant OVA image. Default size is 120 GB
    -n: Name of the resultant OVA image file
    -d: Image distribution can be coreos, rhel, or centos
    -U: Red Hat subscription username (for RHEL)
    -P: Red Hat subscription password (for RHEL)
    -O: OS password (for RHEL and CentOS)
    -T: Scratch space to use for OVA generation (defaults to system specific temp directory, for example, ‘/tmp’).

    Example invocation for RHEL and RHCOS:

     set +o history
     export RHN_USER=my_user
     export RHN_PASSWORD=my_password
     export ROOT_PASSWORD=`openssl rand -base64 12`
     set -o history
    
     python3 convert_qcow2_ova.py -u <path_to_downloaded_rhel_qcow2_image> -n rhel82120.ova.gz -d rhel -U “$RHN_USER” -P “$RHN_PASSWORD” -O “$ROOT_PASSWORD”
    
     python3 convert_qcow2_ova.py -u <path_to_downloaded_rhcos_qcow2_image> -n rchos-454.ova.gz -d coreos
    
  4. After successfully running the script, notice that the OVA image files are available in the current directory.

     $ ls -l
     total 2439224
     -rw-r--r-- 1 root root      18699 Sep 25 07:03 convert_qcow2_ova.py
     -rwxr-xr-x 1 root root       4539 Sep 25 07:03 create_boot_images.py*
     -rw-r--r-- 1 root root       4436 Sep 25 07:03 README.md
     -rw-r--r-- 1 root root 1008885759 Oct  7 14:06 rhcos-454.ova.gz
     -rw-r--r-- 1 root root 1488838411 Oct  7 13:15 rhel82120.ova.gz
     -rwxr-xr-x 1 root root       3410 Sep 25 07:03 upload_image.py*
    

Upload OVA to IBM Cloud Object Storage

Perform the following steps to upload the OVA images to IBM COS:

  1. Create the IBM COS service and bucket. Refer to Getting started with IBM Cloud Object Storage for instructions.

    Power Systems Virtual Server currently supports import from only us-east, us-south, and eu-de regions. Therefore, ensure that you create the Cloud Object Storage bucket in one of these regions.

  2. Create secret and access keys with Hash-Based Message Authentication Code (HMAC). Refer to Using HMAC credentials for instructions.
  3. Run the following command for RHEL and RHCOS:

    python3 upload_image.py -b <cosBucketName> -r <cosRegion> -f <fileUpload> -o <targetObjectName> -a <bucketAccessKey> -s <bucketSecretKey>
    

    Where:
    -b: IBM COS bucket name (example, ocp-images-bucket)
    -r: IBM COS region (example, us-south)
    -f: File to upload (example, rhcos0820.ova.gz)
    -o: Target object name (example, rhcos0820.ova.gz)
    -a: IBM COS bucket access key
    -s: IBM COS bucket secret key

    Note: Ensure that the target object name follows the pattern filename-without-dots.ova.gz. For example, names like rhel8.0408.ova.gz, rhel.ppc64le.ova.gz would cause failures.

    Example:

     set +o history
     export ACCKEY=<access_key>
     export SECRET=<secretkey>
     set -o history
    
     python3 upload_image.py -b rhel-images-powervs -r us-south -f rhel-82.ova.gz -o rhel82120.ova.gz -a $ACCKEY -s $SECRET
    
     python3 upload_image.py -b rhel-images-powervs -r us-south -f rchos-454.ova.gz -o rhcos-454.ova.gz -a $ACCKEY -s $SECRET
    

Summary

After performing the steps in this tutorial, you now have boot images that are ready for use by the Red Hat OpenShift Container Platform clusters on IBM Power Systems Virtual Servers. Go ahead and start importing them into your Power Systems Virtual Server service instance!