Building a RHEL-family image

Build a RHEL-family node image by installing the required packages, matching the kernel modules, pointing chrony at internal time sources, and cleaning the VM before upload.

Use the same starting point, privileges, and Packer guidance as for Ubuntu.

  1. Wait for the first boot to finish, then install the packages.

    On RHEL, enable EPEL by using the Red Hat instructions instead of installing epel-release.

    cloud-init status --wait || true
    dnf install -y epel-release
    dnf install -y \
      conntrack-tools dbus libseccomp nfs-utils python3 python3-kubernetes socat \
      openssh-server openssh-clients cloud-init haproxy chrony ca-certificates
  2. On the RHEL 10 family only, match kernel-modules-extra to the kernel that the image boots.

    Update the kernel first, then reboot so that the running kernel is the one that ships.

    dnf upgrade -y kernel-core
    reboot
    # After the reboot:
    dnf install -y "kernel-modules-extra-$(uname -r)"
    dnf remove -y --oldinstallonly || true
    grubby --default-kernel   # Must print /boot/vmlinuz-<output of uname -r>
  3. Stop the services and timers that must not run or reach out from the image.
    systemctl disable --now haproxy
    systemctl disable --now dnf-makecache.timer
  4. Point chrony at internal time sources.

    This step is required. In /etc/chrony.conf, replace the pool line with server <ntp-server> iburst lines. Bootstrap replaces this file only when the access profile sets NTP servers.

  5. Add your private CA, if you have one, and check that the system trusts it.
    cp internal-ca.crt /etc/pki/ca-trust/source/anchors/internal-ca.crt
    update-ca-trust
    openssl verify -CAfile /etc/pki/tls/certs/ca-bundle.crt \
      /etc/pki/ca-trust/source/anchors/internal-ca.crt
  6. Disable the public repositories.

    On RHEL, also unregister the system from Red Hat.

    sed -i 's/^enabled *= *1/enabled=0/' /etc/yum.repos.d/*.repo
  7. If you use a mirror, add it, and then refresh the package metadata from it to check the mirror, its signing key, and your CA.

    Replace the URLs and the key path with your own, and repeat the section for AppStream and EPEL. Add proxy= to each section if you need a proxy.

    cp RPM-GPG-KEY-internal /etc/pki/rpm-gpg/RPM-GPG-KEY-internal
    cat > /etc/yum.repos.d/internal-mirror.repo <<'EOF'
    [internal-baseos]
    name=Internal BaseOS
    baseurl=<package-mirror>/rocky/$releasever/BaseOS/$basearch/os/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-internal
    EOF
    dnf makecache
  8. Clean up and shut down.

    Do not log in to the VM again after this step.

    dnf clean all
    rm -f /etc/ssh/ssh_host_* /root/.ssh/authorized_keys /home/*/.ssh/authorized_keys
    cloud-init clean --logs --machine-id --seed
    shutdown -h now

The VM is stopped and its disk is ready to upload.