Skip to content
Snippets Groups Projects
Unverified Commit e445d79e authored by Julian Tölle's avatar Julian Tölle Committed by GitHub
Browse files

docs(v2): describe process to prepare VolumeAttachments (#375)

Provide script to prepare VolumeAttachments before migrating to v2.x.y of
the csi-driver.
parent 0b82720f
No related branches found
No related tags found
No related merge requests found
......@@ -113,7 +113,7 @@ In case of a new major version, there might be manual steps that you need to fol
### From v1 to v2
There are two breaking changes between v1.6 and v2.0 that require user intervention. Please take care to follow these steps, as otherwise the update might fail.
There are three breaking changes between v1.6 and v2.0 that require user intervention. Please take care to follow these steps, as otherwise the update might fail.
**Before the rollout**:
......@@ -138,6 +138,15 @@ There are two breaking changes between v1.6 and v2.0 that require user intervent
$ kubectl delete daemonset -n kube-system hcloud-csi-node
```
4. We changed the way the device path of mounted volumes is communicated to the node service. This requires changes to the `VolumeAttachment` objects, where we need to add information to the `status.attachmentMetadata` field. Execute the linked script to automatically add the required information. This requires `kubectl` version `v1.24+`, even if your cluster is running v1.23.
```shell
$ kubectl version
$ curl https://raw.githubusercontent.com/hetznercloud/csi-driver/main/docs/v2-fix-volumeattachments/fix-volumeattachments.sh ./fix-volumeattachments.sh
$ chmod +x ./fix-volumeattachments.sh
$ ./fix-volumeattachments.sh
```
**Rollout the new manifest**:
```shell
......
#!/usr/bin/env bash
set -e -o pipefail
if [ "$DEBUG" != "" ];
then
set -x
fi
DIR="./hcloud-csi-fix-volumeattachments"
echo "[INFO] Creating a new directory to write logs: ${DIR}"
mkdir --parents "${DIR}"
# Logging utility
LOG_FILE="${DIR}/logs.txt"
write_log() {
echo "$1"
echo "$1" >> "${LOG_FILE}"
}
# Verify dependencies
verify_installed() {
cmd="$1"
if ! command -v "$cmd" &> /dev/null
then
write_log "[ERR] For the script to run successfully, \"${cmd}\" is required, but it could not be found. Please make sure it is installed."
exit
fi
}
verify_installed kubectl
verify_installed grep
VOLUME_ATTACHMENTS=$(
kubectl get volumeattachment \
-o custom-columns=NAME:.metadata.name,ATTACHER:.spec.attacher,DEVICEPATH:.status.attachmentMetadata.devicePath \
| { grep -E 'csi\.hetzner\.cloud.*<none>' --color=never || true; } \
| cut --fields=1 --delimiter=' '
)
if [[ -z "$VOLUME_ATTACHMENTS" ]]; then
write_log "[INFO] No affected VolumeAttachments found, exiting."
exit 0
fi
for VOLUME_ATTACHMENT in "$VOLUME_ATTACHMENTS"; do
write_log "[INFO] Processing VolumeAttachment $VOLUME_ATTACHMENT"
PV_NAME=$(
kubectl get volumeattachment \
-o=jsonpath="{.spec.source.persistentVolumeName}" \
"$VOLUME_ATTACHMENT"
)
VOLUME_ID=$(
kubectl get persistentvolume \
-o=jsonpath="{.spec.csi.volumeHandle}" \
"$PV_NAME"
)
write_log "[INFO] VolumeAttachment $VOLUME_ATTACHMENT uses volume $VOLUME_ID"
DEVICE_PATH="/dev/disk/by-id/scsi-0HC_Volume_${VOLUME_ID}"
kubectl patch volumeattachment \
--subresource=status \
--type=strategic \
-p "{\"status\":{\"attachmentMetadata\": {\"devicePath\":\"${DEVICE_PATH}\"}}}" \
"$VOLUME_ATTACHMENT"
write_log "[INFO] Patched VolumeAttachment $VOLUME_ATTACHMENT"
done
write_log "[INFO] Finished processing all VolumeAttachments!"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment