| Matthias Andreas Benkard | 05e482e | 2026-11-04 11:05:51 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Creates a ZFS dataset per PV. The helper pod runs with hostPID, and all |
| 3 | # ZFS and filesystem operations are performed in the host's mount namespace |
| 4 | # (nsenter -t 1 -m). Running zfs directly inside the helper container would |
| 5 | # mount the dataset only inside the container's own mount namespace; the |
| 6 | # workload would then write into the parent dataset, and the child dataset |
| 7 | # would shadow that data after the next host reboot. |
| 8 | set -eu |
| 9 | |
| 10 | while getopts "m:s:p:" opt |
| 11 | do |
| 12 | case $opt in |
| 13 | p) |
| 14 | absolutePath=$OPTARG |
| 15 | ;; |
| 16 | s) |
| 17 | sizeInBytes=$OPTARG |
| 18 | ;; |
| 19 | m) |
| 20 | volMode=$OPTARG |
| 21 | ;; |
| 22 | esac |
| 23 | done |
| 24 | |
| 25 | host() { nsenter -t 1 -m -- "$@"; } |
| 26 | |
| 27 | host zfs create "rpool${absolutePath}" |
| 28 | host zfs mount "rpool${absolutePath}" 2>/dev/null || : |
| 29 | host findmnt -n -o SOURCE "${absolutePath}" | grep -qx "rpool${absolutePath}" |
| 30 | host chmod 0777 "${absolutePath}" |