Skip to main content

How to generate a Red Hat Enterprise Linux 9 image with MicroShift

Learn how to use MicroShift, an exploratory, open source project to bring OpenShift to edge computing and field-deployed devices, to generate a custom RHEL 9 image.
Image
Circular saw cutting metal with flying sparks

Photo by Russ Ward on Unsplash

I was involved in a demo of Red Hat Enterprise Linux (RHEL) for Edge, using MicroShift and ImageBuilder, and I experienced some problems with the network driver for Raspberry Pi 4 in RHEL 8. To solve this problem, I decided to create a custom image based on RHEL 9 instead, and in my previous article, I explain how I did that. If you haven't read that article, please read it before continuing with this article.

(Note: At the time of this writing, there is no RHEL version for Raspberry Pi. RHEL for ARM is available only for larger 64-bit ARMv8 platforms. However, this is based on a demo, and if you need a supported Linux system, try Fedora on Raspberry Pi. Fedora 29 and later supports the Raspberry Pi Model 2B- and 3-series of devices, including the 3B, 3B+, 3A+, 3CM and 3CM+.) 

In this article, I demonstrate how to generate your own RHEL 9 image with MicroShift.

MicroShift is an exploratory project created by Red Hat's edge computing team. Its goal is to tailor OpenShift for field-deployed devices, providing a consistent development and management experience across all footprints.

[ You might also be interested in reading How MicroShift and Kubernetes help manage edge devices at scale. ]

Key technologies

For this challenge, I relied primarily on three key technologies:

  • EC2 Graviton: The AWS Graviton chips are Arm-based 7nm processors designed by AWS and custom-built for cloud workloads. Graviton processors include dedicated cores and caches for each vCPU.
  • Image builder: RHEL's image builder creates installer media that embeds the OSTree commit. This is perfect for disconnected environments requiring an ISO, thumb drive, or some form of media that doesn't depend on network access. In this case, I used the RAW format to ensure compatibility with AWS.
  • MicroShift: This is OpenShift for the Edge and the software the image will run.

[ Free download: Advanced Linux commands cheat sheet. ]

Run an EC2 instance of your RHEL 9 AMI

First, you must run the RHEL 9 AMI you built in the first part of this series:

$ aws ec2 run-instances \
--image-id ami-[the-id-of-your-ami] \
--instance-type t4g.medium \
--subnet-id subnet-[the-id-of-your-subnet] \
--security-group-ids sg-[the-id-of-you-security-group] \
--associate-public-ip-address \
--key-name [the-name-of-your-ssh-key] \
--block-device-mappings "[{\"DeviceName\":\"/dev/xvda\",\"Ebs\":{\"VolumeSize\":60,\"DeleteOnTermination\":true}}]" \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=image-builder}]'

Install image builder

Next, install the image builder package and start it:

$ sudo dnf install -y osbuild-composer
$ sudo systemctl enable --now osbuild-composer.socket

You need to configure image builder with a repository override so that you can add custom repositories (or repositories that are different from the default repositories).

[ Learn how to modernize your IT with managed cloud services. ]

I've already created a configuration for this, so clone my Git repository to get the necessary JSON and TOML files.

  1. Create a configuration directory structure:

    $ mkdir -p /etc/osbuild-composer/repositories
  2. Copy the utils/rhel-90.json to the config directory:

    $ sudo cp utils/rhel-90.json /etc/osbuild-composer/repositories
  3. Add the new repositories (the TOML files in my Git repo) to the server:

    $ composer-cli sources add utils/transmission.toml
    $ composer-cli sources add utils/microshift.toml

Restart image builder so that it detects your changes:

$ sudo systemctl restart osbuild-composer.service

Build the image

You can now build your image, complete with MicroShift installed:

$ composer-cli blueprints push utils/microshift-blueprint-v0.0.1.toml

Orchestrate

This is all developing technology, so you may need to take some additional steps as it evolves, but the principles are the same as always. You're building reproducible images using configuration as code and running the images on the cloud.

There are many use cases for a RHEL image, and not just for edge computing. Build your own image and try it out for your next project.

Check out these related articles on Enable Sysadmin

Image
Typing on a laptop with headphones next to the computer
Red Hat Enterprise Linux 9 offers significant new features for hybrid cloud organizations. Here's how to install it so you can start testing.
Author’s photo

Jose Antonio Gonzalez Prada

Jose Antonio González Prada works for Red Hat as a Specialist Solution Architect, previously as a Senior Consultant, specializing in OpenShift and container-related technologies. More about me

Red Hat Summit 2022: On Demand

Get the latest on Ansible, Red Hat Enterprise Linux, OpenShift, and more from our virtual event on demand.

Related Content

OUR BEST CONTENT, DELIVERED TO YOUR INBOX