diff --git a/infrastructure/system-upgrades/longhorn-lvm.yaml b/infrastructure/system-upgrades/longhorn-lvm.yaml index dd91a558f875cd73711044e45fe31cdcbf56584c..689930773d5492cbd1a12cbe567d4ffaf7e8107d 100644 --- a/infrastructure/system-upgrades/longhorn-lvm.yaml +++ b/infrastructure/system-upgrades/longhorn-lvm.yaml @@ -19,7 +19,7 @@ stringData: echo "Failed to find volume group" >&2 exit 1 fi - + # Setup LVM volume (size) # Since Volume can already exist, we should make sure, we set their size on update if lvs "$VG_NAME" | grep "${LV_NAME}"; then @@ -27,40 +27,40 @@ stringData: else lvcreate --size "$(cat "$secrets/volumesize")" --name "${LV_NAME}" "${VG_NAME}" fi - + # Setup filesystem # After a volume creation or adjustment of the volume size # the filesystem will require either creation or adjustment. if ! file -L -s "/dev/$VG_NAME/$LV_NAME" | grep XFS; then mkfs.xfs "/dev/$VG_NAME/$LV_NAME" fi - + # Setup SELinux labels # cri-o while running SELinux enabled, will require container_file_t to function # properly with non-privileged containers. if ! matchpathcon '/var/lib/longhorn' | grep "container_file_t"; then semanage fcontext -a -t container_file_t "/var/lib/longhorn(/.*)?" fi - + # Prepare mountpoint mkdir -p /var/lib/longhorn # Prepare and setup mountpoint if ! mountpoint /var/lib/longhorn; then mount "/dev/$VG_NAME/$LV_NAME" /var/lib/longhorn fi - + # GrowFS since we can't do it earlier as it needs to be mounted xfs_growfs "/dev/$VG_NAME/$LV_NAME" if ! ls -laZ /var/lib/longhorn | grep "container_file_t"; then restorecon /var/lib/longhorn fi - + # Persist mountpoint if ! grep '/var/lib/longhorn' /etc/fstab; then echo "/dev/mapper/${VG_NAME}-${LV_NAME} /var/lib/longhorn xfs defaults,x-systemd.device-timeout=0 0 0" >> /etc/fstab else - sed -i "s%/dev/mapper/${VG_NAME}-${LV_NAME}*%/dev/mapper/${VG_NAME}-${LV_NAME} /var/lib/longhorn xfs defaults,x-systemd.device-timeout=0 0 0%" /etc/fstab + sed -i "s%^/dev/mapper/${VG_NAME}-${LV_NAME}.*%/dev/mapper/${VG_NAME}-${LV_NAME} /var/lib/longhorn xfs defaults,x-systemd.device-timeout=0 0 0%" /etc/fstab fi systemctl daemon-reload ---