Chapter 5. Deploying a RHEL for Edge image

You can deploy a RHEL for Edge image using the RHEL installer graphical user interface or a Kickstart file. The overall process for deploying a RHEL for Edge image depends on whether your deployment environment is network-based for non-network-based.

Note

To deploy the images on bare metal, use a Kickstart file.

Network-based deployments

Deploying a RHEL for Edge image in a network-based environment involves the following high-level steps:

  1. Extract the image file contents. See Section 3.6, “Downloading a RHEL for Edge image” for information on how to download the RHEL for Edge image
  2. Set up a web server
  3. Install the image

Non-network-based deployments

Deploying a RHEL for Edge image in a non-network-based environment involves the following high-level steps:

  1. Download the RHEL for Edge Container and RHEL for Edge Install. See Section 3.6, “Downloading a RHEL for Edge image” for information on how to download the RHEL for Edge image
  2. Load the RHEL for Edge Container image into Podman
  3. Run the RHEL for Edge Container image into Podman
  4. Load the empty blueprint
  5. Build the RHEL for Edge Installer image
  6. Prepare a qcow disk
  7. Boot the Virtual Machine (VM)
  8. Install the image

5.1. Extracting RHEL for Edge image commit

After you download the commit, extract the .tar file and note the ref name and the commit ID.

The downloaded commit file consists of a .tar file with an OSTree repository. The OSTree repository contains a commit and a compose.json file.

The compose.json file contains information metadata about the commit with information such as the “Ref” (reference ID) and the commit ID. The commit contains the rpm packages.

To extract the package contents, perform the following the steps:

Prerequisites

  • Create a kickstart file or use an existing one.

Procedure

  1. Extract the downloaded image tar file:

    # tar xvf <UUID>-commit.tar
  2. Navigate to the directory where you have extracted the .tar file.

    It contains a compose.json file and an OSTree directory. The compose.json file contains the commit number and the OSTree directory contains the rpm packages.

  3. Open the compose.json file and note the commit ID number. You need this number handy when you proceed to set up a web server.

    If you have the jq JSON processor installed, you can also retrieve the commit hash ID using the jq tool:

    # jq '.["ostree-commit"]' < compose.json
  4. List the rpm packages in the commit.

    # rpm-ostree db list rhel/8/x86_64/edge --repo=repo
  5. Use a Kickstart file to run the RHEL installer. You can either use any existing file or can create one using the Kickstart Generator tool.

    In the Kickstart file, ensure that you include the details about how to provision the file system, create a user, and how to fetch and deploy the RHEL for Edge image. The RHEL installer uses this information during the installation process.

    The following is a Kickstart file example:

    lang en_US.UTF-8
    keyboard us
    timezone Etc/UTC --isUtc
    text
    zerombr
    clearpart --all --initlabel
    autopart
    reboot
    user --name=core --group=wheel
    sshkey --username=core "ssh-rsa AAAA3Nza...."
    
    ostreesetup --nogpg --osname=rhel --remote=edge --url=https://mirror.example.com/repo/ --ref=rhel/8/x86_64/edge

    The ostreesetup command is used to set up OStree-based installations. It fetches the OSTree commit, by using the following flags:

    • --nogpg - Disable GPG key verification.
    • --osname - Management root for OS installation.
    • --remote - Management root for OS installation
    • --url - URL of the repository to install from.
    • --ref - Name of the branch from the repository to be used for installation.
    • --url=https://mirror.example.com/repo/ is the address of the host system where you extracted the edge commit and served over nginx. You can use the address to reach the host system from the guest machine.

      For example, if you extract the commit image in the /var/www/html directory and serve the commit over nginx on a machine whose hostname is www.example.com, the value of the --url parameter is http://www.example.com/repo.

      Note

      Use the http protocol to start a service to serve the commit, because https is not enabled on the Apache HTTP Server.

Additional resources

For more details on how to create a Kickstart file, see:

5.2. Setting up a web server to install RHEL for Edge image

After you have extracted the RHEL for Edge image contents, set up a web server to provide the image commit details to the RHEL installer via HTTP.

The following example provides the steps to set up a web server using a container.

Prerequisites

Procedure

  1. Create the nginx configuration file with the following instructions:

    events {
    
    }
    
    http {
        server{
            listen 8080;
            root /usr/share/nginx/html;
                    }
             }
    
    pid /run/nginx.pid;
    daemon off;
  2. Copy the nginx configuration file to the /etc/nginx.conf directory.
  3. Create a dockerfile with the following instructions:

    FROM registry.access.redhat.com/ubi8/ubi
    RUN yum -y install nginx && yum clean all
    COPY kickstart.ks /var/www/html/
    COPY repo /usr/share/nginx/html/
    EXPOSE 8080
    CMD ["/usr/sbin/nginx", "-c", "/etc/nginx.conf"]

    Where,

    • kickstart.ks is the name of the Kickstart file from the RHEL for Edge image. The kickstart file includes directive information. To help you manage the images later, it is advisable to include the checks and settings for Greenboot checks. To do so, you can update the Kickstart file to include the following settings:

      lang en_US.UTF-8
      keyboard us
      timezone Etc/UTC --isUtc
      text
      zerombr
      clearpart --all --initlabel
      autopart
      reboot
      user --name=core --group=wheel
      sshkey --username=core "ssh-rsa AAAA3Nza...."
      
      ostreesetup --nogpg --osname=rhel --remote=edge
      --url=https://mirror.example.com/repo/
      --ref=rhel/8/x86_64/edge
      
      %post
      cat << EOF > /etc/greenboot/check/required.d/check-dns.sh
      #!/bin/bash
      
      DNS_SERVER=$(grep nameserver /etc/resolv.conf | cut -f2 -d" ")
      COUNT=0
      
      # check DNS server is available
      ping -c1 $DNS_SERVER
      while [ $? != '0' ] && [ $COUNT -lt 10 ]; do
      ((COUNT++))
      echo "Checking for DNS: Attempt $COUNT ."
      sleep 10
      ping -c 1 $DNS_SERVER
      done
      EOF
      %end

      The OSTree repository can be hosted from any HTTP service, and the example, using a container, is just an option for how to do this. The docker file performs the following tasks:

      1. Uses the latest Universal Base Image (ubi)
      2. Installs the web server (nginx)
      3. Adds the kickstart file to the server
      4. Adds the RHEL for Edge image commit to the server
  4. Build a docker container

    #  podman build -t name-of-container-image --build-arg commit=uuid-commit.tar .
  5. Run the container

    #  podman run --rm -d -p port:8080 localhost/name-of-container-image

    As a result, the server is set up and ready to launch the RHEL installer using the commit.tar repository and the kickstart file.

5.3. Downloading RHEL Boot.iso image

You can download a Red Hat Boot ISO image from the Red Hat Customer Portal. The Red Hat Boot ISO image is used to launch the RHEL installer. The installer fetches the Kickstart file that you provide for installing RHEL for Edge images.

Prerequisites

Procedure

  1. Open a browser and access https://access.redhat.com/downloads.
  2. Click the Red Hat Enterprise Linux 8.
  3. Click the button Download Now for the option "Red Hat Enterprise Linux 8.4 Boot ISO"

For more information about downloading Boot.iso image, see Downloading the installation ISO image.

5.4. Installing the RHEL for Edge image using a Kickstart file

To install the RHEL for Edge image using a Kickstart file, use the web server. The web server uses the RHEL for Edge image commit.tar repository and the kickstart file to launch the RHEL installer.

Prerequisites

  • The server to fetch the commit in the Installer is available and running.
  • A disk image to install the commit you created.

Procedure

  1. Run the Anaconda Installer using the libvirt virt-install:

    virt-install \
    --name rhel-edge-test-1
    --memory 2048 \
    --vcpus 2 \
    --disk size=8 \
    --disk path=prepared_disk_image.qcow2,format=qcow2 \
    --os-variant rhel8.4
    --cdrom /home/username/Downloads/rhel-8.4-x86_64-boot.iso
  2. On the installation screen, press TAB to specify an additional kernel parameter:

    inst.ks=http://edge_device_ip:port/kickstart.ks

    The kernel parameter specifies that you want to install RHEL using the Kickstart file and not the RHEL image contained in the RHEL Installer.

    The RHEL Installer starts, fetches the Kickstart file from the server (HTTP) endpoint and executes the commands, including the command to install the RHEL for Edge image commit from the HTTP endpoint. Once the installation is complete, the installer prompts for login details.

  3. On the Login screen, specify your user account credentials and click Enter.
  4. Verify whether the RHEL for Edge image is successfully installed.

    $ rpm-ostree status

    The command output provides the image commit ID and shows that the installation is successful.

    Following is a sample output:

    State: idle
    Deployments:
    * ostree://edge:rhel/8/x86_64/edge
    		  Timestamp: 2020-09-18T20:06:54Z
    			Commit: 836e637095554e0b634a0a48ea05c75280519dd6576a392635e6fa7d4d5e96

5.5. Creating a RHEL for Edge Container image for non-network-based deployments

After you downloaded the RHEL for Edge Container commit, you can build a container by loading the downloaded commit into Podman. For that, perform the following the steps:

Prerequisites

Procedure

  1. Navigate to the directory where you have downloaded the RHEL for Edge Container image.
  2. Load the RHEL for Edge Container image into Podman.

    $ cat ./commit_ID-container.tar | sudo podman load

    The command output provides the image ID, for example: @8e0d51f061ff1a51d157804362bc875b649b27f2ae1e66566a15e7e6530cec63

  3. Tag the new RHEL for Edge Container image, using the image ID generated by the previous step.

    $ sudo podman tag image-ID localhost/edge-container

    The podman tag command assigns an additional name to the local image.

  4. Run the container named edge-container.

    $ sudo podman run --name=edge-container -p 8080:80 localhost/edge-container

    The podman run --name=edge-container command assigns a name to your container based on the localhost/edge-container image.

  5. List containers:

    $  $ podman ps -a
    CONTAINER ID  IMAGE                               	COMMAND	CREATED    	STATUS                	PORTS   NAMES
    2988198c4c4b  …./localhost/edge-container   /bin/bash  3 seconds ago  Up 2 seconds ago      	edge-container

As a result, Podman runs a container that serves a repository with the RHEL for Edge Container commit.

5.6. Creating a RHEL for Edge Installer image for non-network-based deployments

After you have built a running container to serve a repository with the RHEL for Edge Container commit, create an RHEL for Edge Installer (.iso) image. The Installer (.iso) pulls the commit served by RHEL for Edge Container (.tar) by HTTP. After the RHEL for Edge container is loaded in Podman, it exposes the OSTree in the URL format. The following example provides the steps to set up a web server using a container.

Prerequisites

Procedure

  1. On the Image Builder dashboard, for the empty blueprint that you have created for RHEL for Edge image, click Create Image.
  2. On the Create Image window, perform the following steps:

    1. In the Repository textbox, specify the RHEL for Edge container OSTree URL to embed in the image. For example, http://$podman_host_ip:8080/repo
    2. In the Ref textbox, specify the same reference as you provided during the creation of the RHEL for Edge Container commit to embed in the image. For example, rhel/edge/test.
    3. Click Create.

      Image Builder pulls the commit that is being served by the running container during the image build. Once the image build is complete, you can download the resulting image. See Downloading a RHEL for Edge image.

      You can use the same workflow for the CLI. See Creating a RHEL for Edge Installer image using command-line interface for non-network-based deployments.

.

5.7. Installing the RHEL for Edge image for non-network-based deployments

To install the RHEL for Edge image, follow the steps:

Prerequisites

  • You stopped the running container.
  • A disk image to install the commit you created.

Procedure

  1. Create an empty qcow image to install the (.iso). That is an image of a hard drive for the virtual machine (VM). For example:

    $  qemu-img create -f qcow2 diskfile.qcow2 5G
  2. Boot the VM using the disk as a drive and the installer ISO as a CD-ROM. For example:

    $  qemu-system-x86_64 \
              -enable-kvm \
              -m 4G \
              -cpu host \
              -net nic,model=virtio \
              -net user,hostfwd=tcp::2223-:22 \
              -cdrom $HOME/Downloads/Fedora-Server-netinst-x86_64-33-1.2.iso \
              disk-image.img

    This command instructs qemu (the hypervisor) to:

    • Use KVM virtualization.
    • Increase memory to 4000MB (some processes are consuming lots of memory, for example dnf).
    • Use the same CPU type as the host uses.
    • Connect the guest to a virtual network bridge on the host and forward TCP port 2223 from the host to the SSH port (22) on the guest.
    • Mount the installation ISO.
    • Use the hard drive image created above.

      It gives you an Anaconda Installer. The RHEL Installer starts, loads the Kickstart file from the ISO and executes the commands, including the command to install the RHEL for Edge image commit. Once the installation is complete, the installer prompts for login details.

      Note

      Anaconda is preconfigured to use the container commit during the installation.

  3. On the Login screen, specify your user account credentials and click Enter.

Verification steps

  1. Verify whether the RHEL for Edge image is successfully installed.

    $  rpm-ostree status

As a result, the command output provides the image commit ID and shows that the installation is successful.