From cac63fd13aa36192e00ff6683e4e931f4027c493 Mon Sep 17 00:00:00 2001 From: Dobes Vandermeer Date: Fri, 4 Jul 2025 18:57:38 -0700 Subject: [PATCH] Update working-with-instancegroups.md Add an example script to setup RAID-10 for instances with multiple NVMe disks. --- docs/tutorial/working-with-instancegroups.md | 33 ++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/tutorial/working-with-instancegroups.md b/docs/tutorial/working-with-instancegroups.md index 48a8550613..51026ee618 100644 --- a/docs/tutorial/working-with-instancegroups.md +++ b/docs/tutorial/working-with-instancegroups.md @@ -387,6 +387,39 @@ $ df -h | grep nvme[12] > Note: at present its up to the user ensure the correct device names. +Some AWS instances provide multiple NVMe disks instead of a single device. You can use an additionalUserData to create a RAID array from those disks +and then use volumeMounts to mount and format that virtual device, for example: + +``` +apiVersion: kops.k8s.io/v1alpha2 +kind: InstanceGroup +metadata: + labels: + kops.k8s.io/cluster: my-beloved-cluster + name: database +spec: + # ... + additionalUserData: + - content: | + #!/bin/bash + set -eo pipefail + if ! [ -e /dev/md0 ] ; then + DEVICES=($(lsblk -rp -I 259 -o NAME,MODEL | grep 'Amazon\\x20EC2\\x20NVMe' | cut -d ' ' -f 1)) + DEVICE_COUNT=${#DEVICES[@]} + echo Found ${DEVICE_COUNT} NVMe disks: ${DEVICES[@]} + if [[ $DEVICE_COUNT > 1 ]] ; then + mdadm --create /dev/md0 --level=10 --raid-devices=${DEVICE_COUNT} ${DEVICES[@]} + fi + fi + name: 00-setup-raid.sh + type: text/x-shellscript + volumeMounts: + - device: /dev/md0 + filesystem: xfs + path: /data + +``` + ## Creating a new instance group Suppose you want to add a new group of nodes, perhaps with a different instance type. You do this using `kops create ig --subnet `. Currently the