Integrate with Apptainer

Charmed HPC can integrate with Apptainer to enable container workload scheduling with Slurm. This guide explains how to enable container workload scheduling by deploying and integrating Apptainer with Charmed HPC.

New to Apptainer?

If you’re unfamiliar with operating Apptainer installations, see the Apptainer admin quick start guide for a high-level introduction to administering Apptainer.

Prerequisites

Deploy Apptainer

First, use juju deploy to deploy Apptainer in the slurm model on your charmed-hpc machine cloud:

juju deploy apptainer
Tip: Switching between Juju models

juju switch can be used to determine the current model you’re operating on:

user@host:~$
juju switch
charmed-hpc-controller:admin/slurm

The output above shows that you’re operating on the slurm model as the admin user through the Juju controller charmed-hpc-controller.

juju switch <model> can also be used to switch between models:

user@host:~$
juju switch identity
charmed-hpc-controller:admin/slurm -> charmed-hpc-controller:admin/identity

The output above shows that you’ve switched from operating on your slurm model to your identity model.

Integrate Apptainer with Slurm

Next, use juju integrate to integrate Apptainer with Slurm:

juju integrate apptainer sackd
juju integrate apptainer slurmd
juju integrate apptainer slurmctld

Apptainer will install itself on all the sackd and slurmd units, and will share its configuration with the Slurm controller service, slurmctld.

Verify that Apptainer is integrated with Slurm

Use juju exec to submit a test job.

For example, to submit a test job where the runtime environment is Ubuntu 22.04, run:

juju exec -u sackd/0 -- \
  srun --partition slurmd --container=docker://ubuntu:22.04 \
  cat /etc/os-release | grep ^VERSION

If Apptainer has been successfully integrated with Slurm, the output of the test job will be similar to the following:

user@host:~$
juju exec -u sackd/0 -- srun --partition slurmd --container=docker://ubuntu:22.04 cat /etc/os-release | grep ^VERSION
INFO:    Converting OCI blobs to SIF format
INFO:    Starting build...
INFO:    Fetching OCI image...
INFO:    Extracting OCI image...
INFO:    Inserting Apptainer configuration...
INFO:    Creating SIF file...
VERSION_ID="22.04"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy

Next steps

You can now use Apptainer to run workloads and build container images on your Charmed HPC cluster. Explore the Use Apptainer how-to for more information on using Apptainer on your Charmed HPC cluster.