Update working-with-instancegroups.md

Add an example script to setup RAID-10 for instances with multiple NVMe disks.
This commit is contained in:
Dobes Vandermeer 2025-07-04 18:57:38 -07:00 committed by GitHub
parent aeaed55a30
commit cac63fd13a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 0 deletions

View File

@ -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 <InstanceGroupName> --subnet <zone(s)>`. Currently the