From 9ae6b2b0da76a32feac849024fcc573f4c438087 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Wed, 26 Feb 2025 19:43:34 +0100 Subject: [PATCH] linstor: add basic snapshot functionality Signed-off-by: Andrei Kvapil --- .../core/platform/bundles/distro-full.yaml | 2 +- packages/core/platform/bundles/paas-full.yaml | 2 +- .../linstor/templates/plunger/configmap.yaml | 15 ++++++ .../linstor/templates/plunger/plunger.yaml | 52 +++++++++++++++++++ .../templates/volumesnapshotclass.yaml | 8 +++ 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 packages/system/linstor/templates/plunger/configmap.yaml create mode 100644 packages/system/linstor/templates/plunger/plunger.yaml create mode 100644 packages/system/linstor/templates/volumesnapshotclass.yaml diff --git a/packages/core/platform/bundles/distro-full.yaml b/packages/core/platform/bundles/distro-full.yaml index 0c1ad6de..d44eb3df 100644 --- a/packages/core/platform/bundles/distro-full.yaml +++ b/packages/core/platform/bundles/distro-full.yaml @@ -174,7 +174,7 @@ releases: chart: cozy-linstor namespace: cozy-linstor privileged: true - dependsOn: [piraeus-operator,cilium,cert-manager] + dependsOn: [piraeus-operator,cilium,cert-manager,snapshot-controller] - name: telepresence releaseName: traffic-manager diff --git a/packages/core/platform/bundles/paas-full.yaml b/packages/core/platform/bundles/paas-full.yaml index c6492440..d4892a31 100644 --- a/packages/core/platform/bundles/paas-full.yaml +++ b/packages/core/platform/bundles/paas-full.yaml @@ -205,7 +205,7 @@ releases: chart: cozy-linstor namespace: cozy-linstor privileged: true - dependsOn: [piraeus-operator,cilium,kubeovn,cert-manager] + dependsOn: [piraeus-operator,cilium,kubeovn,cert-manager,snapshot-controller] - name: snapshot-controller releaseName: snapshot-controller diff --git a/packages/system/linstor/templates/plunger/configmap.yaml b/packages/system/linstor/templates/plunger/configmap.yaml new file mode 100644 index 00000000..8a303812 --- /dev/null +++ b/packages/system/linstor/templates/plunger/configmap.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: linstor-plunger + namespace: cozy-linstor +data: + plunger.sh: | + #!/bin/bash + set -e + while true; do + # workaround for https://github.com/LINBIT/linstor-server/issues/437 + linstor -m s l | jq -r '.[][] | select(.flags | contains(["DELETE"])) | "linstor snapshot delete \(.resource_name) \(.name)"' | sh -x + sleep 1m + done diff --git a/packages/system/linstor/templates/plunger/plunger.yaml b/packages/system/linstor/templates/plunger/plunger.yaml new file mode 100644 index 00000000..83b67891 --- /dev/null +++ b/packages/system/linstor/templates/plunger/plunger.yaml @@ -0,0 +1,52 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: linstor-plunger + namespace: cozy-linstor +spec: + replicas: 1 + selector: + matchLabels: + app: linstor-plunger + template: + metadata: + labels: + app: linstor-plunger + annotations: + checksum/config: {{ include (print $.Template.BasePath "/plunger/configmap.yaml") . | sha256sum }} + spec: + containers: + - name: plunger + image: quay.io/piraeusdatastore/piraeus-server:v1.29.2 + command: ["/bin/bash", "/scripts/plunger.sh"] + volumeMounts: + - mountPath: /etc/linstor/client + name: client-tls + readOnly: true + - mountPath: /etc/linstor + name: etc-linstor + readOnly: true + - mountPath: /scripts + name: script-volume + readOnly: true + enableServiceLinks: false + serviceAccountName: linstor-controller + tolerations: + - effect: NoSchedule + key: drbd.linbit.com/lost-quorum + - effect: NoSchedule + key: drbd.linbit.com/force-io-error + volumes: + - name: client-tls + projected: + sources: + - secret: + name: linstor-client-tls + - name: etc-linstor + configMap: + name: linstor-controller-config + - name: script-volume + configMap: + name: linstor-plunger + defaultMode: 0755 diff --git a/packages/system/linstor/templates/volumesnapshotclass.yaml b/packages/system/linstor/templates/volumesnapshotclass.yaml new file mode 100644 index 00000000..4e950f3f --- /dev/null +++ b/packages/system/linstor/templates/volumesnapshotclass.yaml @@ -0,0 +1,8 @@ +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshotClass +metadata: + annotations: + snapshot.storage.kubernetes.io/is-default-class: "true" + name: linstor-snapshots +driver: linstor.csi.linbit.com +deletionPolicy: Delete