# File-backed LVM so the home filesystem cannot grow past 150Gi. # The node root disk is one ext4; a 152Gi image is the volume group, the LV is 150Gi. apiVersion: apps/v1 kind: DaemonSet metadata: name: cursor-devbox-lvm namespace: cursor-devbox spec: selector: matchLabels: app: cursor-devbox-lvm template: metadata: labels: app: cursor-devbox-lvm spec: hostPID: true tolerations: - operator: Exists containers: - name: setup image: ubuntu:24.04 imagePullPolicy: IfNotPresent securityContext: privileged: true command: ["nsenter", "-t", "1", "-m", "-u", "-i", "--", "bash", "-c"] args: - | set -euo pipefail mkdir -p /var/lib/cursor-devbox /usr/local/sbin /mnt/cursor-devbox-home cat > /usr/local/sbin/cursor-devbox-lvm-setup << 'EOF' #!/bin/bash set -euo pipefail IMG=/var/lib/cursor-devbox/backing.img MNT=/mnt/cursor-devbox-home mkdir -p /var/lib/cursor-devbox "$MNT" if [ ! -f "$IMG" ]; then fallocate -l 152G "$IMG" fi if ! losetup -j "$IMG" | grep -q .; then losetup -f "$IMG" fi LOOP=$(losetup -j "$IMG" | awk -F: 'NR==1 {print $1}') if ! vgs cursor-devbox >/dev/null 2>&1; then pvcreate "$LOOP" vgcreate cursor-devbox "$LOOP" fi vgchange -ay cursor-devbox if ! lvs cursor-devbox/home >/dev/null 2>&1; then lvcreate -L 150G -n home cursor-devbox mkfs.ext4 -F /dev/cursor-devbox/home fi if ! mountpoint -q "$MNT"; then mount /dev/cursor-devbox/home "$MNT" fi EOF chmod 755 /usr/local/sbin/cursor-devbox-lvm-setup cat > /etc/systemd/system/cursor-devbox-lvm.service << 'EOF' [Unit] Description=Cursor devbox home LVM DefaultDependencies=no After=local-fs.target Before=k3s.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/local/sbin/cursor-devbox-lvm-setup [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable cursor-devbox-lvm.service /usr/local/sbin/cursor-devbox-lvm-setup sleep infinity resources: requests: cpu: 20m memory: 32Mi limits: cpu: 500m memory: 256Mi --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: cursor-devbox-lvm provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer --- apiVersion: v1 kind: PersistentVolume metadata: name: cursor-devbox-home spec: capacity: storage: 150Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain storageClassName: cursor-devbox-lvm local: path: /mnt/cursor-devbox-home nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - ssdnodes-6aa563e76974d