Warewulf 4.x VNFS Containers

HPC
Containers
Published

March 28, 2023

Modified

March 28, 2023

Warewulf – https://warewulf.org …uses Linux containers as template images for bare-metal compute nodes…

In Warewulf terminology images are called VNFS (Virtual Node File System)…

# container images
>>> du -h /var/lib/warewulf/container/rocky-8*.img{,.gz}
1021M   /var/lib/warewulf/container/rocky-8.img
477M    /var/lib/warewulf/container/rocky-8.img.gz

# list a container root files-system
tree $(wwctl container show rocky-8)

Compute nodes download the CPIO archives from the network using iPXE before booting.

Import from Docker

The Warewulf documentation includes a chapter about container mangement

# import a RockyLinux 8 container image 
>>> wwctl container import docker://ghcr.io/hpcng/warewulf-rockylinux:8 rocky-8

# list available containers
>>> wwctl container list
CONTAINER NAME   NODES  KERNEL VERSION   CREATION TIME        MODIFICATION TIME    SIZE    
rocky-8          0      4.18.0-425.13.1.el8_7.x86_64 28 Mar 23 04:58 UTC  28 Mar 23 05:04 UTC  2.5 GiB 

Manual Modification

Make changes to a container with the container exec sub-command…

>>> wwctl container exec rocky-8 /bin/bash
[rocky-8] Warewulf> dnf install -y chrony ntpstat
[rocky-8] Warewulf> cat > /etc/systemd/system/set-timezone.service <<EOF
[Unit]
Description=Set the time zone to Europe/Berlin

[Service]
ExecStart=/usr/bin/timedatectl set-timezone Europe/Berlin
RemainAfterExit=yes
Type=oneshot

[Install]
WantedBy=multi-user.target
EOF
[rocky-8] Warewulf> systemctl enable set-timezone.service
[rocky-8] Warewulf> exit

…a --bind option is available to bind-mount from the host. The VNFS will be automatically rebuild when the command finishes.

Build with Apptainer

The section Creating Containers From Scratch in the Warewulf User Guide explains how to build custom containers.

One option is to use Apptainer – http://apptainer.org/

# install Apptainer
sudo dnf install -y epel-release && sudo dnf install -y apptainer wget

# ...work in a disposable directory
cd $(mktemp -d /var/tmp/$USER-apptainer-XXXXXX)

# ...locate all artifacts within this directory
export APPTAINER_TMPDIR=$PWD
export APPTAINER_CACHEDIR=$PWD

Download the Apptainer definition files are provided on Github – https://github.com/hpcng/warewulf

# ...download the Apptainer definition from the Warewulf project
wget https://raw.githubusercontent.com/hpcng/warewulf/main/containers/Apptainer/rocky-8.def

# ...build the container in an chroot directory (this needs to be done as root)
apptainer build --sandbox chroot/ rocky-8.def

Import the container to Warewulf…

wwctl container import chroot/ rocky-8-custom

# ...associate the container to a node
wwctl node set --container rocky-8-custom ${node}

Install and configure additional components modify the Apptainer definition file rocky-8.

Following is an example for NTP time synchronisation and setting of the timezone…

# rocky-8.def
# ...
dnf install -y chrony ntpstat

cat > /etc/systemd/system/set-timezone.service <<EOF
[Unit]
Description=Set the time zone to Europe/Berlin

[Service]
ExecStart=/usr/bin/timedatectl set-timezone Europe/Berlin
RemainAfterExit=yes
Type=oneshot

[Install]
WantedBy=multi-user.target
EOF
systemctl enable set-timezone.service

Update the container root file-system in chroot

# overwrite the previous container root file-system
apptainer build --sandbox --update chroot/ rocky-8.def

# import as container image overwriting the previous version
wwctl container import --update chroot/ rocky-8-custom

Build with Podman

Docker Warewulf images are build from a repository on GitHub – https://github.com/hpcng/warewulf-node-images

# ...install Podman
dnf install -y podman git

# ...clone the repository from GitHub
cd /tmp && \
  git clone https://github.com/hpcng/warewulf-node-images && \
  cd warewulf-node-images/rockylinux-8

Build the container image from its definition file…

podman build -f Containerfile --tag rocky-8

# ...export the container image to a TAR archive...
podman save localhost/rocky-8:latest -o /tmp/rocky-8.tar

Import the archive file to Warewulf…

wwctl container import --update file://tmp/rocky-8.tar rocky-8-custom