Chapter 6. Creating and uploading a customized RHEL system image to Microsoft Azure using Red Hat Image Builder

The ability to create customized RHEL system images using Red Hat Image Builder and upload those images to the Microsoft Azure cloud target environment is available.

6.1. Authorizing Red Hat Image Builder to push images to Microsoft Azure Cloud

To authorize Red Hat Image Builder to push images to the Microsoft Azure cloud, you must configure Red Hat Image Builder as an authorized application and give it the role of Contributor; for that, follow the steps:

Prerequisites

  • You have a Storage account created in Microsoft Azure.
  • You have an existing resource group in Azure portal.

Procedure

  1. Access Red Hat Image Builder on the browser of your preference. This redirects you to the Red hat Image Builder dashboard.
  2. Click Create image.
  3. In the Image output window:

    1. From the dropdown menu, select the Release: Red Hat Enterprise Linux (RHEL) 8.3.
    2. Select Microsoft Azure as the Target environment.
    3. Click Next.
  4. In the Target Environment - Upload to Microsoft Azure window:

    1. Click Authorize Image Builder on Azure to authorize Red Hat Image Builder to push images to the Microsoft Azure cloud.

      1. Click the Authorize Image Builder on Azure link. This redirects you to the Microsoft Azure portal.
      2. Login with your credentials.
      3. You are required to accept the Permission requested. Click Accept.
      4. Type Resources Group in the search bar and select the first entry under Services. This redirects you to the Resources Group dashboard.
      5. Select your Resource Group. This redirects you to the Resource Group dashboard.
      6. On the left menu, click Access control (IAM) to add a permission so the Red Hat Image Builder application can access your resources group.
      7. From the menu, click the tab *Role assignments.
      8. Click +Add.
      9. From the dropdown menu, choose Add role assignment. A menu appears on the left side.
      10. Insert the following details:

        1. Role: Assign the role Contributor
        2. Assign access to: User, group, service principal
        3. Select: Image Builder application

With the previous configuration, you assign the role to your Resource Group and thus authorizing the Red Hat Image Builder application to push images to Microsoft Azure cloud.

Note

Even though any user can add an application to the resources group/ project, the application is not able to see any resource unless the account administrator adds the shared application to the IAM.

Verification

  • From the menu, click the tab Role assignments.

    You can see Red Hat Image Builder set as a Contributor of the Resource Groups you selected.

6.2. Creating a customized RHEL system image for Microsoft Azure using Image Builder

Follow the steps in this procedure to create customized system images using Image Builder and upload those images to Microsoft Azure.

Prerequisites

Procedure

  1. Access Red Hat Image Builder on the browser of your choice.

    You are redirected to the Red Hat Image Builder dashboard.

  2. Click Create image.
  3. In the Image output window:

    1. From the dropdown menu, select the Release: Red Hat Enterprise Linux (RHEL) 8.3.
    2. Select Microsoft Azure as the Target environment.

      Click Next.

  4. In the Target Environment - Upload to Microsoft Azure window:

    1. Click Authorize Image Builder on Azure to authorize Red Hat Image Builder to push images to the Microsoft Azure cloud. See Section 6.1, “Authorizing Red Hat Image Builder to push images to Microsoft Azure Cloud” for details.

      Note

      Ensure you completed the steps from the previous section, otherwise Red Hat Image Builder will not be able to upload an image into your Microsoft Azure account.

  5. Under Destination, enter the following details:

    1. Tenant ID: you can find your Tenant ID in the Azure Active Directory application in Microsoft Azure Portal.
    2. Subscription ID: you can find your Subscription ID account by accessing the Microsoft Azure console.
    3. Resource Group: is the name of your Resource Group in Microsoft Azure Portal.

      Click Next.

  6. In the Registration window, you have the option to:

  7. Optional: In the Additional package window, add packages to your image. See Chapter 4, Adding packages during image creation by Using Red Hat Image Builder.
  8. In the Review window, review the details about the image creation and click Create.

    Red Hat Image Builder starts the compose of a RHEL 8.3 Azure Disk Image image for the x86_64 architecture, uploads it to the resource group account you specified, and creates an Azure Image.

    The Red Hat Image Builder Images dashboard opens. You can see details such as the Image UUID, the cloud target environment, the image OS release and the status of the image creation. Once the status is Ready, the Azure Disk Image is shared with the specified account.

    Possible statuses:

    • Pending: the image upload and cloud registration is being processed.
    • In Progress: the image upload and cloud registration is ongoing.
    • Ready: the image upload and cloud registration is completed
    • Failed: the image upload and cloud registration failed.

      Note

      The image build, upload and cloud registration processes can take up to ten minutes to complete.

Verification

  • Check if the image status is Ready. It means that the image upload and cloud registration is completed successfully.

6.3. Accessing your customized RHEL system image from your Microsoft Azure account

After the image is built, uploaded and the cloud registration process status is marked as Ready, you can access the Azure Disk Image from your Microsoft Azure account.

Prerequisites

Procedure

  1. Access your Microsoft Azure dashboard and navigate to the Resource group page.
  2. On the overview menu, you can see the image you uploaded is available.

Verification

  1. Once you access your Microsoft Azure Account, you should be able to see the image successfully shared with the resource group account you specified.

    1. If the image is not visible there, you may have issues with the upload process. Return to the Red Hat Image Builder dashboard and check if the image is marked as Ready.

6.4. Creating a Virtual Machine from the customized RHEL system image you shared with the Microsoft Azure account

This section describes steps to create a Virtual Machine (VM) from the image you shared with the Microsoft Azure Cloud account by using Red Hat Image Builder.

Prerequisites

Procedure

  1. Click + Create VM. You are redirected to the Create a virtual machine dashboard.
  2. In the Basic tab under Project Details, your Subscription and the Resource Group are pre-set.

    Optional: If you want to create a new resource Group:

    1. Click Create new.

      A pop-up prompts you to create the Resource Group Name container.

    2. Insert a name and click OK.

      If you want to keep the Resource Group that is already pre-set.

  3. Under Instance Details, insert:

    1. Virtual machine name
    2. Region
    3. Image:
    4. Size: Choose a VM size that better suits your needs.

      Keep the remaining fields as in the defaults choice.

  4. Under Administrator account, enter the following details:

    1. Username: the name of the account administrator.
    2. SSH public key source: from the drop-down menu, select Generate new key pair.
    3. Key pair name: insert a name for the key pair.
  5. Under Inbound port rules:

    1. Public inbound ports: select Allow selected ports.
    2. Select inbound ports: Use the default set SSH (22).
  6. Click Review + Create. You are redirected to the Review + create tab. You will receive a confirmation that the validation passed.
  7. Review the details and click Create.

    Optionally, you can click Previous if you want to change the previous options.

  8. A Generates New Key Pair pop-up opens. Click Download private key and create resources.

    Save the key file in the yourKey.pem file format.

  9. Once the deployment is complete, click Go to resource.

    You are redirected to a new window with your VM details.

  10. Select the public IP address on the top right side of the page and copy it to your clipboard.

Verification

To connect to the Virtual Machine you created, create an SSH connection. Now, to create an SSH connection with the VM to connect to the Virtual Machine.

  1. Open a terminal.
  2. At your prompt, open an SSH connection to your virtual machine. Replace the IP address with the one from your VM, and replace the path to the .pem file with the path to where the key file was downloaded.

    # ssh -i <yourKey.pem file location> <username>@<IP_address>
    • Add the user name and replace the IP address with the one from your VM.
    • Replace the path to the .pem file with the path to where the key file was downloaded.

      For example:

      # ssh -i ./Downloads/yourKey.pem azureuser@10.111.12.123
  3. You are required to confirm if you want to continue to connect. Type yes to continue.

    As a result, the output image you shared with the Azure Storage account is started and ready to be provisioned.