Skip to main content

2 posts tagged with "rhel"

View All Tags

Creating a MicroShift bootable image with Podman Desktop

· 7 min read
Charlie Drage
Software Engineer

banner

If you're unfamiliar with BootC, it offers an impressive method for deploying applications directly to bare metal from either a single Containerfile or a pre-existing bootc-supported image.

A "bootable" image, known as a BootC container image, allows you to use a simple container image to create a full bootable operating system, whether it's a raw virtual machine image or an iso for USB installation!

This capability is ideal for a variety of uses, from a simple HTTP server to an OS powering a full-stack application.

In this tutorial, we'll deploy an OpenShift derivative called MicroShift, an edge-optimized version of OpenShift designed for single-node setups on resource-constrained configurations. Think of it as a compact version of OpenShift!

This entire process is carried out using a single Containerfile (or Dockerfile).

Requirements

Before starting the tutorial, ensure you have:

Building the BootC container image

First, we'll build the initial BootC container image from which we'll later create a bootable OS.

Logging into Red Hat registry

Before proceeding, download the Red Hat Authentication extension from the catalog to enable access to Red Hat registries:

red hat login

Then log into your account:

red hat login sign in

Download your OpenShift Hybrid Cloud pull secret

Download your pull secret.

This is downloaded as pull-secret.txt. Put it in a secure location.

Creating the Containerfile (or Dockerfile)

The Containerfile is crucial for creating the bootable image.

It's important to note that we will be providing one argument during the build and that is the PASSWORD in order to access the Virtual Machine that will be logged in via the redhat username.

We will be using the Containerfile from the MicroShift image mode GitHub documentation.

Copy the Containerfile from the above link to a new file which we will be building with Podman Desktop:

$ curl https://raw.githubusercontent.com/openshift/microshift/main/docs/config/Containerfile.bootc-rhel9 -o Containerfile

Build with Podman Desktop

Select the Containerfile and build it within Podman Desktop.

You will need to provide:

  • A password for the redhat user that will be created in the Containerfile.

Pass the argument as USER_PASSWD in the build page arguments.

build

Build the bootable image with BootC Podman Desktop extension

Install

Install the BootC Podman Desktop extension from the extensions catalog:

install

Build the image

Now, create the bootable image from our container image!

Click the new BootC icon on the navigation bar and go to build:

build_button

Once the build is complete, you'll see a confirmation on the dashboard.

Next, select the image we built and choose an appropriate output format for testing the bootable image. RAW is a common choice for local testing with QEMU and other VM software like libvirt.

Testing the image

Explore various ways to test your image, using local software or cloud platforms. Here are some common steps for using the RAW output bootable image.

Running the Virtual Machine

This guide doesn't cover all methods for running a virtual machine, but here are the most common:

When using Hyper-V, create a .vhd image with BootC:

  1. When building, select the .vhd option.
  2. Install Hyper-V
  3. Import the virtual machine

Configuring and verifying MicroShift

After you boot your virtual machine, you can now configure MicroShift as well as verify the connection.

Copying over the OpenShift pull secret

Before proceeding with verifying OpenShift, the OpenShift pull secret must be copied over so that MicroShift can download Red Hat registry-authenticated container images.

Below we will copy the OpenShift secret you had previously downloaded to the virtual machine.

  1. Download your OpenShift pull secret which is downloaded as pull-secret.txt

  2. Use scp to copy over to the virtual machine:

$ scp -P 2222 pull-secret.txt redhat@localhost:~/
  1. SSH into the VM:
$ ssh redhat@localhost -p 2222
  1. Move the secret to /etc/crio/openshift-pull-secret:
$ sudo mv pull-secret.txt /etc/crio/openshift-pull-secret
  1. Restart the microshift service:
$ sudo systemctl restart microshift

Listing pods

Below we will SSH into the virtual machine and confirm that MicroShift is deploying Pods correctly:

  1. SSH into the VM:
$ ssh redhat@localhost -p 2222
  1. Copy the generated kubeconfig file to ~/.kube/config:
$ mkdir -p ~/.kube
$ sudo cp /var/lib/microshift/resources/kubeadmin/kubeconfig ~/.kube/config
$ sudo chown redhat ~/.kube/config
  1. Verify Pods are running by using oc or kubectl:
$ kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system csi-snapshot-controller-856bb8b9bc-9n7lj 1/1 Running 1 3d23h
kube-system csi-snapshot-webhook-7c64d4d4d7-98v6l 1/1 Running 1 3d23h
openshift-dns dns-default-n2td4 2/2 Running 2 3d23h
openshift-dns node-resolver-7cslg 1/1 Running 1 3d23h
openshift-ingress router-default-7cbc67954b-nqqc6 1/1 Running 1 3d23h
openshift-ovn-kubernetes ovnkube-master-zcqw5 4/4 Running 5 3d23h
openshift-ovn-kubernetes ovnkube-node-crnn9 1/1 Running 2 3d23h
openshift-service-ca service-ca-6799f567-k7lsc 1/1 Running 1 3d23h

Using Podman Desktop to verify MicroShift

Alternatively, you can copy the MicroShift configuration file to your local machine and test it remotely on Podman Desktop.

  1. On your local machine, create the .kube directory if it does not exist already:
$ mkdir ~/.kube
  1. Copy the remote kubeconfig file to a local configuration file:

Within MicroShift, a kubeconfig file is automatically created at /var/lib/microshift/resources/kubeadmin/kubeconfig.

Copy the file over to your local system:

scp -P 2222 redhat@localhost:/var/lib/microshift/resources/kubeadmin/kubeconfig ~/config

If you already have a ~/.kube/config, copy the contents of config to the ~/.kube/config file.

  1. Use Podman Desktop to verify the MicroShift cluster:

Podman Desktop will automatically detect your .kube/config file.

Note: You may need to modify your .kube/config file to reflect the correct domain or IP address of your cluster.

cluster

Storage configuration

By default, storage configuration requires an LVM partition and LVMS storage manager will not be deployed. This is due to a limitation when building a RAW image. An alternative non-local storage solution is required to use OpenShift artifacts with storage capabilities. The feature to add LVM support is tracked in this pull request.

Conclusion

This tutorial provided a step-by-step guide on deploying a bootable MicroShift image using Podman Desktop and the BootC extension. By leveraging tools such as BootC and Podman, we've streamlined the process of creating a lightweight, yet fully functional, OpenShift environment suitable for single-node edge computing scenarios.

Thank you for following along, and happy deploying!

Using RHEL as a WSL podman machine

· 5 min read
Jeff Maury
Engineering Manager

Red Hat provides a tool called Image Builder that allows developers to build their own custom image of RHEL in a variety of formats. Recently, Image Builder added WSL as a target, enabling you to run RHEL on Windows as a WSL distribution.

This article details the steps and actions required to build and run your RHEL WSL image.

The purpose of this article is to describe the options needed for the RHEL WSL distribution so that it can be used as a Podman machine.

To use the RHEL WSL image as a Podman machine, ensure that the following packages are installed:

  • podman
  • podman-docker
  • procps-ng
  • openssh-server
  • net-tools
  • iproute
  • dhcp-client
  • sudo
  • systemd-networkd

Luckily, all but the last package are available from the pre-configured RHEL 9 repositories. The last package (systemd-networkd) is available from the EPEL 9 repository and will need to be configured when building the image.

Build the image

Navigate to image builder

image builder

On the upper right menu, enable the Preview mode.

image builder preview

Click Add blueprint to open the Create image dialog wizard.

image wizard

On the Image output page, select the following:

  • From the Release list, select Red Hat Enterprise Linux (RHEL) 9.
  • From the Select target environments option, select WSL - Windows Subsystem for Linux (.tar.gz).
  • Click Next.

On the Register page, select Automatically register and enable advanced capabilities.

On the OpenSCAP page, as it is not supported for WSL images, click Next.

On the File system configuration page, select Recommended: Use automatic partitioning.

  • Click Next.

On the Content page, complete the following steps to add additional packages to your image:

  • On the Repository snapshot step:

    • Select Use latest content.
    • Click Next.
  • On the Custom repositories step:

custom repositories

Click on the Create and manage repositories here link. This will open a new tab

custom repositories

Click Add repositories now

add custom repository

Click Add repositories

add custom repository

On the Add custom repositories page, select the following:

Close the tab and switch back to the previous one

  • In the filter input field, type EPEL
  • Select the EPEL 9 repository

custom repository created

Click Next

  • On the Additional packages step:

    • On the Available packages search field, enter podman and click the button.
    • Select the podman and podman-docker packages.
    • On the Available packages search field, enter procps-ng and click the button.
    • Select the procps-ng package.
    • On the Available packages search field, enter openssh-server and click the button.
    • Select the openssh-server package.
    • On the Available packages search field, enter net-tools and click the button.
    • Select the net-tools package.
    • On the Available packages search field, enter iproute and click the button.
    • Select the iproute package.
    • On the Available packages search field, enter dhcp-client and click the button.
    • Select the dhcp-client package.
    • On the Available packages search field, enter sudo and click the button.
    • Select the sudo package and click the > button to add the selected package shown in the package search results to the Chosen packages dual list box.
    • On the Available packages search field, enter systemd and click the button.
    • Select the systemd-networkd package.
    • Click Next

On the First boot script configuration page:

  • Click Next.

On the Details page:

  • In the Blueprint name, enter rhel-wsl.
  • Click Next.

On the Review page:

  • Click Create blueprint and build image.

images list

The image is being built. Once the build is finished, the download link will be available. Click on the Download (.tar.gz) link and save the downloaded file to one of your local folders.

Create the RHEL WSL podman machine

Launch Podman Desktop and go to the Settings -> Resources page:

images list

On the Podman provider, click on Create new ...

On the Create Podman machine page, click the Browse button for the Image Path field and select the file downloaded from Image Builder.

create podman machine

Click on the Create button: the machine will be created and started. After a short time, the operation status should be reported.

podman machine created

Let's play with the RHEL WSL podman machine

Go to the Images page and pull the httpd image

pull httpd image

Click on Done

images list

Start the image by clicking on the Run image icon

images list

Once the container is started, the Apache server can be accessed on http://localhost:9000