Skip to content

Latest commit

 

History

History
134 lines (105 loc) · 4.93 KB

File metadata and controls

134 lines (105 loc) · 4.93 KB

Building and developing Red Hat Enterprise Linux CoreOS

Background

RHEL CoreOS (RHCOS) is a derivative of Red Hat Enterprise Linux (RHEL), CentOS Strema CoreOS (SCOS) and Fedora CoreOS (FCOS). The tool to build RHCOS, SCOS and FCOS is coreos-assembler. The process detailled here is thus very similar to the one described in Building Fedora CoreOS or Building and developing CentOS Stream CoreOS but requires access to Red Hat internal resources.

Build process

Note that this documentation applies only to RHCOS versions starting with 4.19 and later. For version from 4.9 to 4.18, see the documentation from openshift/os (4.18 branch). For versions older than 4.9, see the internal documentation.

  • Make sure you're meeting the prerequisites.

  • Make sure that you have setup the Red Hat internal CA on your system and that you are connected to the Red Hat VPN.

  • Setup a cosa alias, following the upstream documentation.

    • Note: If you encounter DNS resolution issues with COSA when on the Red Hat VPN, you should try adding --net=host to the podman invocation.
  • Create and use a dedicated directory:

    $ mkdir rhcos
    $ cd rhcos
    

    If you're going to work on RHCOS based on different versions of RHEL, using a dedicated directory for each RHEL version is recommended:

    $ mkdir rhcos-rhel-10.2
    $ cd rhcos-rhel-10.2
    
  • Make sure that you have setup the latest internal Red Hat root certificates on your host system. See the internal documentation.

  • Make sure that you have the latest cosa alias from the documentation. Then ask COSA to use those certificates:

    $ export COREOS_ASSEMBLER_ADD_CERTS='y'
    
  • Get the following value from the internal documentation:

    $ export RHCOS_REPO="..."
    
  • Clone the config repo (coreos/rhel-coreos-config), passing as argument the internal Git repo which includes the RPM repo configs and optionaly the specific branch:

    # Main developement branch, default version
    $ cosa init --yumrepos "${RHCOS_REPO}" https://github.com/coreos/rhel-coreos-config.git
    
    # Main developement branch, selecting a specific variant
    $ cosa init --yumrepos "${RHCOS_REPO}" --variant rhel-10.2 https://github.com/coreos/rhel-coreos-config.git
    
    # Specific develepment branch, selecting a specific variant
    $ cosa init --yumrepos "${RHCOS_REPO}" --variant rhel-10.2 --branch foobar https://github.com/coreos/rhel-coreos-config.git
    
  • Authenticate to the Red Hat Stage Registry (registry.stage.redhat.io):

    The base container images for RHCOS are hosted on registry.stage.redhat.io, which requires authentication. Without this, cosa build will fail with an unauthorized error when pulling the base image.

    1. Create an account at Red Hat Subscription Management (Ethel) if you don't already have one.

    2. Log in to the registry from your host:

      $ podman login registry.stage.redhat.io
      
    3. Share the registry credentials with the COSA container so that buildah inside the container can pull from registry.stage.redhat.io:

      $ export COREOS_ASSEMBLER_CONTAINER_RUNTIME_ARGS="-v /run/user/$(id -u)/containers/auth.json:/tmp/auth.json:ro -e REGISTRY_AUTH_FILE=/tmp/auth.json"
      
  • Fetch packages and build RHCOS ostree container and QEMU image:

    $ cosa fetch
    $ cosa build
    

Building RHCOS images for other platforms than QEMU

  • You can build images for platforms that are supported in COSA using the buildextend commands:
    $ cosa osbuild aws
    $ cosa osbuild openstack
    

Running RHCOS locally for testing

  • You may then run an ephemeral virtual machine using QEMU with:
    $ cosa run
    

Testing RHCOS with kola

  • You may then run tests on the image built with kola:
    # Run basic QEMU scenarios
    $ cosa kola run basic*
    # Run all kola tests (internal & external)
    $ cosa kola run --parallel 2
    

Overriding packages for testing

  • If you need to override a file or a package for local testing, you can place those into the override/rootfs or override/rpm directory before building the image. See the Using overrides section from the COSA documentation.