Last active
December 2, 2025 08:24
-
-
Save thomaspeitz/eaef87c714418eb1fe1a732655d4637b to your computer and use it in GitHub Desktop.
Karpenter EC2NodeClass aws mount nvme /var/lib/containerd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: karpenter.k8s.aws/v1beta1 | |
| kind: EC2NodeClass | |
| metadata: | |
| name: gitlab-runner | |
| spec: | |
| amiFamily: AL2023 | |
| blockDeviceMappings: [] | |
| userData: | | |
| MIME-Version: 1.0 | |
| Content-Type: multipart/mixed; boundary="BOUNDARY" | |
| --BOUNDARY | |
| Content-Type: text/x-shellscript; charset="us-ascii" | |
| #!/bin/bash | |
| echo "Running a custom user data script" | |
| set -ex | |
| yum install -y mdadm nvme-cli rsync | |
| systemctl stop containerd | |
| nvme_disks=($(nvme list | grep "Amazon EC2 NVMe Instance Storage" | awk -F'[[:space:]][[:space:]]+' '{print $1}')) | |
| if [[ ${#nvme_disks[@]} -ge 2 ]]; then | |
| mdadm --create --verbose /dev/md0 --level=0 --raid-devices=${#nvme_disks[@]} ${nvme_disks[*]} && | |
| mkfs.ext4 -F /dev/md0 && | |
| mv /var/lib/containerd/ /var/lib/containerd-original && | |
| mkdir /var/lib/containerd && | |
| mount /dev/md0 /var/lib/containerd && | |
| rsync -a /var/lib/containerd-original/ /var/lib/containerd/ && | |
| rm -rf /var/lib/containerd-original && | |
| chmod 750 /var/lib/containerd && | |
| systemctl start containerd | |
| else | |
| echo "Not enough NVMe disks available for RAID 0 configuration." | |
| fi | |
| --BOUNDARY-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, with the approach above ^ karpenter will not be able to schedule nodes if pods are requesting ephemeral storage
The correct way to use NVME is to set
https://karpenter.sh/v1.7/concepts/nodeclasses/#specinstancestorepolicy