From 04fa2ebdbf449a288c6ff33f33728268742f20e5 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 11:40:28 +0100
Subject: [PATCH 01/12] swh: Allow centralized pv/pvcs declaration

This allows to share the pv/pvcs declaration instead of duplicating it inside
the various templates using it (e.g. graph, alter, cassandra-checks, ...)

Refs. swh/infra/sysadm-environment#5593
---
 .../volumes/persistent-volume-claims.yaml     | 20 +++++
 swh/templates/volumes/persistent-volume.yaml  | 15 ++++
 swh/values.yaml                               | 82 +++++++++++++++----
 3 files changed, 99 insertions(+), 18 deletions(-)
 create mode 100644 swh/templates/volumes/persistent-volume-claims.yaml
 create mode 100644 swh/templates/volumes/persistent-volume.yaml

diff --git a/swh/templates/volumes/persistent-volume-claims.yaml b/swh/templates/volumes/persistent-volume-claims.yaml
new file mode 100644
index 000000000..dee383a94
--- /dev/null
+++ b/swh/templates/volumes/persistent-volume-claims.yaml
@@ -0,0 +1,20 @@
+{{ if .Values.volumes.enabled -}}
+{{- range $pvcName, $pvcConfig := .Values.volumes.persistentVolumeClaims }}
+{{- if or (not (hasKey $pvcConfig "enabled")) (get $pvcConfig "enabled") -}}
+{{- $namespace := $pvcConfig.namespace | default $.Values.namespace -}}
+{{- $appName := $pvcConfig.appName -}}
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: {{ $pvcName }}
+  namespace: {{ $namespace }}
+  {{- if $appName }}
+  labels:
+    app: {{ $appName }}
+  {{- end }}
+spec:
+    {{- toYaml $pvcConfig.spec | nindent 2 }}
+{{ end }}
+{{ end }}
+{{ end }}
diff --git a/swh/templates/volumes/persistent-volume.yaml b/swh/templates/volumes/persistent-volume.yaml
new file mode 100644
index 000000000..819d9f43b
--- /dev/null
+++ b/swh/templates/volumes/persistent-volume.yaml
@@ -0,0 +1,15 @@
+{{ if .Values.volumes.enabled -}}
+{{- range $pvName, $pvConfig := .Values.volumes.persistentVolumes }}
+{{- if or (not (hasKey $pvConfig "enabled")) (get $pvConfig "enabled") -}}
+{{- $namespace := $pvConfig.namespace | default $.Values.namespace -}}
+---
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: {{ $pvName }}
+  namespace: {{ $namespace }}
+spec:
+    {{- toYaml $pvConfig.spec | nindent 2 }}
+{{ end }}
+{{ end }}
+{{ end }}
diff --git a/swh/values.yaml b/swh/values.yaml
index a4a17d526..e74f3d059 100644
--- a/swh/values.yaml
+++ b/swh/values.yaml
@@ -1915,6 +1915,61 @@ rpcLocalRustWithGrpcGraphConfiguration:
   grpc_server:
     port: 50091
 
+volumes:
+  enabled: true
+  # Where to declare the pvs and pvcs (can be overridden per instance)
+  # namespace: swh
+  # Dictionary of persistent volumes specification
+  persistentVolumes: {}
+    # Dictionary of persistent volumes specification
+    # graph-20240331-persistent-local-pv:
+    #   # Can be disabled, enabled by default if not provided
+    #   enabled: true
+    #   # namespace: swh-cassandra
+    #   # The pv's specification, this is the raw yaml supported by kubernetes
+    #   spec:
+    #     capacity:
+    #       storage: 1Gi
+    #     volumeMode: Filesystem
+    #     accessModes:
+    #     - ReadWriteOnce
+    #     persistentVolumeReclaimPolicy: Retain
+    #     storageClassName: local-storage
+    #     local:
+    #       path: /srv/softwareheritage/ssd/graph/2024-03-31/compressed
+    #     nodeAffinity:
+    #       required:
+    #         nodeSelectorTerms:
+    #         - matchExpressions:
+    #           - key: kubernetes.io/hostname
+    #             operator: In
+    #             values: rancher-node-highmem02
+  # Dictionary of persistent volume claims specification
+  persistentVolumeClaims: {}
+    # graph-20240331-persistent-pvc:
+    #   enabled: true
+    #   # optional application name to whom this pv is associated
+    #   appName: graph-20240331
+    #   spec:
+    #     storageClassName: local-storage
+    #     volumeMode: Filesystem
+    #     volumeName: graph-20240331-persistent-pv
+    #     accessModes:
+    #     - ReadWriteOnce
+    #     resources:
+    #       requests:
+    #         storage: 1Gi
+    # graph-20240331-inmemory-pvc:
+    #   enabled: true
+    #   spec:
+    #     storageClassName: local-path
+    #     volumeMode: Filesystem
+    #     accessModes:
+    #     - ReadWriteOnce
+    #     resources:
+    #       requests:
+    #         storage: 1Gi
+
 graph:
   enabled: false
   # rpc port (can be overriden per instance)
@@ -1990,26 +2045,16 @@ graph:
     #   # Define the volumes where to mount the data
     #   extraVolumes:
     #     graph-python3k-persistent:
-    #       mountPath: /srv/dataset
-    #       persistentVolumeClaimDefinition:
-    #         storageClassName: local-persistent
-    #         volumeMode: Filesystem
-    #         accessModes:
-    #         - ReadWriteOnce
-    #         resources:
-    #           requests:
-    #             storage: 1Gi
+    #       enabled: true
+    #       spec:
+    #         mountPath: /srv/dataset
+    #         pvcName: graph-python3k-persistent-pvc
     #     # in-memory volumes
     #     graph-python3k-inmemory:
-    #       mountPath: /srv/graph
-    #       persistentVolumeClaimDefinition:
-    #         storageClassName: local-path
-    #         volumeMode: Filesystem
-    #         accessModes:
-    #         - ReadWriteOnce
-    #         resources:
-    #           requests:
-    #            storage: 1Gi
+    #       enabled: true
+    #       spec:
+    #         mountPath: /srv/graph
+    #         pvcName: graph-python3k-inmemory-pvc
     #   # Deploy an ingress to access swh graph
     #   ingress:
     #     enabled: false
@@ -2022,3 +2067,4 @@ graph:
     #       default:
     #         paths:
     #           - path: /
+
-- 
GitLab


From fc837599c01a1cc73d747c1e64085d3cc1edc355 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 11:40:43 +0100
Subject: [PATCH 02/12] graph: Rewrote pv/pvcs declaration using the new
 `volumes` template

Refs. swh/infra/sysadm-environment#5593
---
 swh/templates/graph/deployment.yaml           |   3 +-
 .../graph/persistent-volume-claims.yaml       |  54 --------
 swh/values/local-cluster.yaml                 |  85 +++++++-----
 swh/values/production/swh-cassandra.yaml      | 121 ++++++++++++++----
 swh/values/staging/next-version.yaml          |  47 ++++---
 swh/values/staging/swh-cassandra.yaml         |  45 ++++---
 6 files changed, 211 insertions(+), 144 deletions(-)
 delete mode 100644 swh/templates/graph/persistent-volume-claims.yaml

diff --git a/swh/templates/graph/deployment.yaml b/swh/templates/graph/deployment.yaml
index 6c83cb5a7..b21a1fe34 100644
--- a/swh/templates/graph/deployment.yaml
+++ b/swh/templates/graph/deployment.yaml
@@ -219,9 +219,10 @@ spec:
           name: backend-utils
           defaultMode: 0555
       {{- range $volumeName, $volumeConfig := $graphConfig.extraVolumes }}
+      {{- $pvcName := $volumeConfig.pvcName | default (print $volumeName "-pvc") }}
       - name: {{ $volumeName }}
         persistentVolumeClaim:
-          claimName: {{ $volumeName }}-pvc
+          claimName: {{ $pvcName }}
       {{ end }}
 {{ end }}
 {{ end -}}
diff --git a/swh/templates/graph/persistent-volume-claims.yaml b/swh/templates/graph/persistent-volume-claims.yaml
deleted file mode 100644
index 78cddf636..000000000
--- a/swh/templates/graph/persistent-volume-claims.yaml
+++ /dev/null
@@ -1,54 +0,0 @@
-{{ if .Values.graph.enabled -}}
-{{ range $graphType, $graphConfig := .Values.graph.deployments }}
-{{- if or (not (hasKey $graphConfig "enabled")) (get $graphConfig "enabled") -}}
-{{- range $volumeName, $volumeConfig := $graphConfig.extraVolumes }}
-{{- if $volumeConfig.persistentVolumeClaimDefinition -}}
-{{- include "swh.persistentVolumeClaim"
-  (dict "volumeName"   $volumeName
-        "serviceType"  ( print "graph-" $graphType )
-        "volumeConfig" $volumeConfig
-        "Values"       $.Values) -}}
-{{- else if eq $volumeConfig.persistentVolumeType "local" -}}
----
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: {{ $volumeName }}-local-pv
-  namespace: {{ $.Values.namespace }}
-spec:
-  capacity:
-    storage: 1Gi
-  volumeMode: Filesystem
-  accessModes:
-  - ReadWriteOnce
-  persistentVolumeReclaimPolicy: Retain
-  storageClassName: local-storage
-  local:
-    path: {{ $volumeConfig.nodePath }}
-  nodeAffinity:
-    required:
-      nodeSelectorTerms:
-      - matchExpressions:
-        - key: kubernetes.io/hostname
-          operator: In
-          values: {{ $volumeConfig.nodes | toYaml | nindent 12 }}
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: {{ $volumeName }}-pvc
-  namespace: {{ $.Values.namespace }}
-spec:
-  resources:
-    requests:
-      storage: 1Gi
-  volumeMode: Filesystem
-  volumeName: {{ $volumeName }}-local-pv
-  storageClassName: local-storage
-  accessModes:
-  - ReadWriteOnce
-{{ end }}
-{{ end }}
-{{ end }}
-{{ end }}
-{{ end }}
diff --git a/swh/values/local-cluster.yaml b/swh/values/local-cluster.yaml
index c1ac2d782..8b46bf32d 100644
--- a/swh/values/local-cluster.yaml
+++ b/swh/values/local-cluster.yaml
@@ -1536,6 +1536,55 @@ externalServices:
       internalName: svix-test
       target: local-cluster-control-plane
 
+volumes:
+  enabled: true
+  persistentVolumeClaims:
+    grpc-example-dataset-example-pvc:
+      enabled: true
+      appName: graph-grpc-example
+      spec:
+        storageClassName: local-persistent
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+    graph-example-inmemory-pvc:
+      enabled: true
+      appName: graph-grpc-example
+      spec:
+        storageClassName: local-path
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+    graph-popular-persistent-pvc:
+      enabled: true
+      appName: graph-popular
+      spec:
+        storageClassName: local-persistent
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+    # in-memory volumes
+    graph-popular-inmemory-pvc:
+      enabled: true
+      appName: graph-popular
+      spec:
+        storageClassName: local-path
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+
 graph:
   enabled: false
   imageVersion: "20241105.2"
@@ -1572,25 +1621,11 @@ graph:
         # persistent volume
         grpc-example-dataset-example:
           mountPath: /srv/dataset
-          persistentVolumeClaimDefinition:
-            storageClassName: local-persistent
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: grpc-example-dataset-example-pvc
         # in-memory volumes
         graph-example-inmemory:
           mountPath: /srv/graph
-          persistentVolumeClaimDefinition:
-            storageClassName: local-path
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: graph-example-inmemory-pvc
       hosts:
         - graph-grpc-example-ingress
       ingress:
@@ -1643,25 +1678,11 @@ graph:
       extraVolumes:
         graph-popular-persistent:
           mountPath: /srv/dataset
-          persistentVolumeClaimDefinition:
-            storageClassName: local-persistent
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: graph-popular-persistent-pvc
         # in-memory volumes
         graph-popular-inmemory:
           mountPath: /srv/graph
-          persistentVolumeClaimDefinition:
-            storageClassName: local-path
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: graph-popular-inmemory-pvc
       hosts:
         - graph-grpc-popular-ingress
       ingress:
diff --git a/swh/values/production/swh-cassandra.yaml b/swh/values/production/swh-cassandra.yaml
index 5d511adcd..167c8c2fb 100644
--- a/swh/values/production/swh-cassandra.yaml
+++ b/swh/values/production/swh-cassandra.yaml
@@ -2503,6 +2503,98 @@ rpcWithRemoteGrpc20241206GraphConfiguration:
 plainGrpcGraphConfiguration:
   max_ram: 500g
 
+volumes:
+  enabled: true
+  persistentVolumes:
+    graph-20240331-persistent-local-pv:
+      enabled: false
+      spec:
+        capacity:
+          storage: 1Gi
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        persistentVolumeReclaimPolicy: Retain
+        storageClassName: local-storage
+        local:
+          path: /srv/softwareheritage/ssd/graph/2024-03-31/compressed
+        nodeAffinity:
+          required:
+            nodeSelectorTerms:
+            - matchExpressions:
+              - key: kubernetes.io/hostname
+                operator: In
+                values:
+                - rancher-node-highmem02
+    graph-20241206-persistent-local-pv:
+      enabled: true
+      spec:
+        capacity:
+          storage: 1Gi
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        persistentVolumeReclaimPolicy: Retain
+        storageClassName: local-storage
+        local:
+          path: /srv/softwareheritage/ssd/graph/2024-12-06/compressed
+        nodeAffinity:
+          required:
+            nodeSelectorTerms:
+            - matchExpressions:
+              - key: kubernetes.io/hostname
+                operator: In
+                values:
+                - rancher-node-highmem01
+
+  persistentVolumeClaims:
+    graph-20240331-persistent-pvc:
+      enabled: false
+      appName: graph-grpc-20240331
+      spec:
+        resources:
+          requests:
+            storage: 1Gi
+        accessModes:
+        - ReadWriteOnce
+        volumeMode: Filesystem
+        volumeName: graph-20240331-persistent-local-pv
+        storageClassName: local-storage
+    graph-20240331-inmemory-pvc:
+      enabled: false
+      appName: graph-grpc-20240331
+      spec:
+        storageClassName: local-path
+        accessModes:
+        - ReadWriteOnce
+        volumeMode: Filesystem
+        resources:
+          requests:
+            storage: 1Gi
+    graph-20241206-persistent-pvc:
+      enabled: true
+      appName: graph-grpc-20241206
+      spec:
+        resources:
+          requests:
+            storage: 1Gi
+        volumeMode: Filesystem
+        volumeName: graph-20241206-persistent-local-pv
+        storageClassName: local-storage
+        accessModes:
+        - ReadWriteOnce
+    graph-20241206-inmemory-pvc:
+      enabled: true
+      appName: graph-grpc-20241206
+      spec:
+        storageClassName: local-path
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+
 graph:
   enabled: true
   deployments:
@@ -2519,22 +2611,13 @@ graph:
       prepareMemoryVolume: true
       extraVolumes:
         graph-20240331-persistent:
-          persistentVolumeType: local
           mountPath: /srv/dataset/2024-03-31/compressed
-          nodePath: /srv/softwareheritage/ssd/graph/2024-03-31/compressed
-          nodes:
-            - rancher-node-highmem02
+          pvcName: graph-20240331-persistent-pvc
+
         # in-memory volumes
         graph-20240331-inmemory:
           mountPath: /srv/graph
-          persistentVolumeClaimDefinition:
-            storageClassName: local-path
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: graph-20240331-inmemory-pvc
       hosts:
         - graph-grpc-20240331-ingress
       ingress:
@@ -2587,22 +2670,12 @@ graph:
       prepareMemoryVolume: true
       extraVolumes:
         graph-20241206-persistent:
-          persistentVolumeType: local
           mountPath: /srv/dataset/2024-12-06/compressed
-          nodePath: /srv/softwareheritage/ssd/graph/2024-12-06/compressed
-          nodes:
-            - rancher-node-highmem01
+          pvcName: graph-20241206-persistent-pvc
         # in-memory volumes
         graph-20241206-inmemory:
           mountPath: /srv/graph
-          persistentVolumeClaimDefinition:
-            storageClassName: local-path
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: graph-20241206-inmemory-pvc
       hosts:
         - graph-grpc.internal.softwareheritage.org
         - graph-grpc-20241206-ingress
diff --git a/swh/values/staging/next-version.yaml b/swh/values/staging/next-version.yaml
index 82e697fcd..ddd6a30a6 100644
--- a/swh/values/staging/next-version.yaml
+++ b/swh/values/staging/next-version.yaml
@@ -1262,6 +1262,34 @@ rpcWithRemoteGrpcGraphConfiguration:
 plainGrpcGraphConfiguration:
   max_ram: 1g
 
+volumes:
+  enabled: true
+  persistentVolumeClaims:
+    swh-graph-grpc-dataset-example-pvc:
+      enabled: true
+      appName: graph-grpc-example
+      spec:
+        storageClassName: local-persistent
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+    # in-memory volume (where the *.graph files and links to the files in persistent
+    # volume are)
+    swh-graph-grpc-inmemory-pvc:
+      enabled: true
+      appName: graph-grpc-example
+      spec:
+        storageClassName: local-path
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+        volumeMode: Filesystem
+
 graph:
   enabled: true
   deployments:
@@ -1284,27 +1312,12 @@ graph:
         # persistent volume (where the full dataset files are stored)
         swh-graph-grpc-dataset-example:
           mountPath: /srv/dataset
-          persistentVolumeClaimDefinition:
-            storageClassName: local-persistent
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: swh-graph-grpc-dataset-example-pvc
         # in-memory volume (where the *.graph files and links to the files in persistent
         # volume are)
         swh-graph-grpc-inmemory:
           mountPath: /srv/graph
-          persistentVolumeClaimDefinition:
-            storageClassName: local-path
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
-            volumeMode: Filesystem
-
+          pvcName: swh-graph-grpc-inmemory-pvc
       hosts:
         - graph-grpc-next-version.internal.staging.swh.network
         - graph-grpc-next-version-ingress
diff --git a/swh/values/staging/swh-cassandra.yaml b/swh/values/staging/swh-cassandra.yaml
index c1f2e6673..cdcc70a96 100644
--- a/swh/values/staging/swh-cassandra.yaml
+++ b/swh/values/staging/swh-cassandra.yaml
@@ -2423,6 +2423,33 @@ rpcWithRemoteGrpcGraphConfiguration:
 plainGrpcGraphConfiguration:
   max_ram: 1g
 
+volumes:
+  enabled: true
+  persistentVolumeClaims:
+    graph-python3k-persistent-pvc:
+      enabled: true
+      appName: graph-grpc-python3k
+      spec:
+        storageClassName: local-persistent
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+    # in-memory volumes
+    graph-python3k-inmemory-pvc:
+      enabled: true
+      appName: graph-grpc-python3k
+      spec:
+        storageClassName: local-path
+        volumeMode: Filesystem
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+
 graph:
   enabled: true
   deployments:
@@ -2443,25 +2470,11 @@ graph:
       extraVolumes:
         graph-python3k-persistent:
           mountPath: /srv/dataset
-          persistentVolumeClaimDefinition:
-            storageClassName: local-persistent
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: graph-python3k-persistent-pvc
         # in-memory volumes
         graph-python3k-inmemory:
           mountPath: /srv/graph
-          persistentVolumeClaimDefinition:
-            storageClassName: local-path
-            volumeMode: Filesystem
-            accessModes:
-            - ReadWriteOnce
-            resources:
-              requests:
-                storage: 1Gi
+          pvcName: graph-python3k-inmemory-pvc
       hosts:
         - graph-grpc.internal.staging.swh.network
         - graph-grpc-ingress
-- 
GitLab


From 68d194d53af68e5f5056cbd25aaeef5cb47be001 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 12:09:00 +0100
Subject: [PATCH 03/12] cassandraChecks: Drop unused volumeClaim configuration
 entry

Refs. swh/infra/sysadm-environment#5593
---
 swh/templates/cassandra-checks/deployment.yaml | 17 -----------------
 swh/values/staging/swh-cassandra.yaml          |  4 ----
 2 files changed, 21 deletions(-)

diff --git a/swh/templates/cassandra-checks/deployment.yaml b/swh/templates/cassandra-checks/deployment.yaml
index c3c8c1105..ee15ad0b5 100644
--- a/swh/templates/cassandra-checks/deployment.yaml
+++ b/swh/templates/cassandra-checks/deployment.yaml
@@ -1,22 +1,5 @@
 {{- if .Values.cassandraChecks.enabled -}}
 
-{{- if and .Values.cassandraChecks.volumeClaim -}}
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: {{ .Values.cassandraChecks.volumeClaim.name }}
-  namespace: swh-cassandra
-spec:
-  storageClassName: {{ .Values.cassandraChecks.volumeClaim.storageClassName }}
-  accessModes:
-    - ReadWriteMany
-  volumeMode: Filesystem
-  resources:
-    requests:
-      storage: {{ $.Values.cassandraChecks.volumeClaim.size | default "20Gi" }}
-{{ end }}
-
 {{ range $service_type, $deployment_config := .Values.cassandraChecks.deployments -}}
 {{- if or (not (hasKey $deployment_config "enabled")) (get $deployment_config "enabled") -}}
 {{- $service_name := ( print "cassandra-checks-" $service_type ) -}}
diff --git a/swh/values/staging/swh-cassandra.yaml b/swh/values/staging/swh-cassandra.yaml
index cdcc70a96..df8236723 100644
--- a/swh/values/staging/swh-cassandra.yaml
+++ b/swh/values/staging/swh-cassandra.yaml
@@ -2212,10 +2212,6 @@ cassandraChecks:
   #   volumeDefinition:
   #     persistentVolumeClaim:
   #       claimName: cassandra-checks-pvc
-  # volumeClaim:
-  #   storageClassName: cephfs
-  #   name: cassandra-checks-pvc
-  #   size: 20Gi
 
   priorityClassName: swh-background-workload
   nodeSelector:
-- 
GitLab


From f5f91c338016f181ec8c6768d8d363a8aae7c33d Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 12:11:05 +0100
Subject: [PATCH 04/12] volumes/persistentVolume: Add appName label to pv

Refs. swh/infra/sysadm-environment#5593
---
 swh/templates/volumes/persistent-volume.yaml | 5 +++++
 swh/values/production/swh-cassandra.yaml     | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/swh/templates/volumes/persistent-volume.yaml b/swh/templates/volumes/persistent-volume.yaml
index 819d9f43b..6b03f5b86 100644
--- a/swh/templates/volumes/persistent-volume.yaml
+++ b/swh/templates/volumes/persistent-volume.yaml
@@ -2,12 +2,17 @@
 {{- range $pvName, $pvConfig := .Values.volumes.persistentVolumes }}
 {{- if or (not (hasKey $pvConfig "enabled")) (get $pvConfig "enabled") -}}
 {{- $namespace := $pvConfig.namespace | default $.Values.namespace -}}
+{{- $appName := $pvConfig.appName -}}
 ---
 apiVersion: v1
 kind: PersistentVolume
 metadata:
   name: {{ $pvName }}
   namespace: {{ $namespace }}
+  {{- if $appName }}
+  labels:
+    app: {{ $appName }}
+  {{- end }}
 spec:
     {{- toYaml $pvConfig.spec | nindent 2 }}
 {{ end }}
diff --git a/swh/values/production/swh-cassandra.yaml b/swh/values/production/swh-cassandra.yaml
index 167c8c2fb..25dd619dc 100644
--- a/swh/values/production/swh-cassandra.yaml
+++ b/swh/values/production/swh-cassandra.yaml
@@ -2508,6 +2508,7 @@ volumes:
   persistentVolumes:
     graph-20240331-persistent-local-pv:
       enabled: false
+      appName: graph-grpc-20240331
       spec:
         capacity:
           storage: 1Gi
@@ -2528,6 +2529,7 @@ volumes:
                 - rancher-node-highmem02
     graph-20241206-persistent-local-pv:
       enabled: true
+      appName: graph-grpc-20241206
       spec:
         capacity:
           storage: 1Gi
-- 
GitLab


From 6a3ee78c12a1854ffc3b51ee17a593399c9e9eeb Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 12:15:10 +0100
Subject: [PATCH 05/12] volumes/pv(c): Fix indentation

Refs. swh/infra/sysadm-environment#5593
---
 swh/templates/volumes/persistent-volume-claims.yaml | 2 +-
 swh/templates/volumes/persistent-volume.yaml        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/swh/templates/volumes/persistent-volume-claims.yaml b/swh/templates/volumes/persistent-volume-claims.yaml
index dee383a94..b0c3b2ead 100644
--- a/swh/templates/volumes/persistent-volume-claims.yaml
+++ b/swh/templates/volumes/persistent-volume-claims.yaml
@@ -14,7 +14,7 @@ metadata:
     app: {{ $appName }}
   {{- end }}
 spec:
-    {{- toYaml $pvcConfig.spec | nindent 2 }}
+  {{- toYaml $pvcConfig.spec | nindent 2 }}
 {{ end }}
 {{ end }}
 {{ end }}
diff --git a/swh/templates/volumes/persistent-volume.yaml b/swh/templates/volumes/persistent-volume.yaml
index 6b03f5b86..a7ea1affc 100644
--- a/swh/templates/volumes/persistent-volume.yaml
+++ b/swh/templates/volumes/persistent-volume.yaml
@@ -14,7 +14,7 @@ metadata:
     app: {{ $appName }}
   {{- end }}
 spec:
-    {{- toYaml $pvConfig.spec | nindent 2 }}
+  {{- toYaml $pvConfig.spec | nindent 2 }}
 {{ end }}
 {{ end }}
 {{ end }}
-- 
GitLab


From a18a846694e4712e9e0e72862db5dfe50c053d48 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 12:25:31 +0100
Subject: [PATCH 06/12] alter: Rewrote pv/pvcs declaration using the new
 `volumes` template

Refs. swh/infra/sysadm-environment#5593
---
 swh/templates/alter/deployment.yaml      | 23 -----------------------
 swh/values/local-cluster.yaml            | 17 +++++++++++------
 swh/values/production/swh-cassandra.yaml | 18 +++++++++++-------
 swh/values/staging/swh-cassandra.yaml    | 19 +++++++++++--------
 4 files changed, 33 insertions(+), 44 deletions(-)

diff --git a/swh/templates/alter/deployment.yaml b/swh/templates/alter/deployment.yaml
index 67150762d..7ef7f5263 100644
--- a/swh/templates/alter/deployment.yaml
+++ b/swh/templates/alter/deployment.yaml
@@ -1,28 +1,5 @@
 {{- if .Values.alter.enabled -}}
 
-{{- if .Values.alter.deployment.volumeClaim -}}
-{{- $volumeMode := .Values.alter.deployment.volumeClaim.volumeMode -}}
-{{- $accessModes := .Values.alter.deployment.volumeClaim.accessModes -}}
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: {{ .Values.alter.deployment.volumeClaim.name }}
-  namespace: {{ .Values.namespace }}
-spec:
-  storageClassName: {{ .Values.alter.deployment.volumeClaim.storageClassName }}
-  {{- if $accessModes }}
-  accessModes:
-    {{- toYaml $accessModes | nindent 4 }}
-  {{- end }}
-  {{- if $volumeMode }}
-  volumeMode: {{ $volumeMode }}
-  {{- end }}
-  resources:
-    requests:
-      storage: {{ .Values.alter.deployment.volumeClaim.size | default "20Gi" }}
-{{ end }}
-
 {{- $service_name := "alter" -}}
 {{- $configurationChecksum := include "alter.configmap" (dict "serviceType" $service_name "Values" .Values) | sha256sum -}}
 {{- $affinity := .Values.alter.deployment.affinity -}}
diff --git a/swh/values/local-cluster.yaml b/swh/values/local-cluster.yaml
index 8b46bf32d..3bfed62bd 100644
--- a/swh/values/local-cluster.yaml
+++ b/swh/values/local-cluster.yaml
@@ -1410,12 +1410,6 @@ alter:
       volumeDefinition:
         persistentVolumeClaim:
           claimName: alter-recovery-bundles-pvc
-    volumeClaim:
-      storageClassName: standard
-      name: alter-recovery-bundles-pvc
-      accessModes:
-        - ReadWriteOnce
-      size: 1Gi
   inventoryStorageConfigurationRef: rpcROStorageConfiguration
   graphConfigurationRef: graphConfiguration
   restorationStorageConfigurationRef: rpcRWStorageConfiguration
@@ -1539,6 +1533,17 @@ externalServices:
 volumes:
   enabled: true
   persistentVolumeClaims:
+    alter-recovery-bundles-pvc:
+      enabled: true
+      appName: alter
+      spec:
+        storageClassName: standard
+        volumeMode: Filesystem
+        accessModes:
+          - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
     grpc-example-dataset-example-pvc:
       enabled: true
       appName: graph-grpc-example
diff --git a/swh/values/production/swh-cassandra.yaml b/swh/values/production/swh-cassandra.yaml
index 25dd619dc..85b2763dd 100644
--- a/swh/values/production/swh-cassandra.yaml
+++ b/swh/values/production/swh-cassandra.yaml
@@ -2550,6 +2550,17 @@ volumes:
                 - rancher-node-highmem01
 
   persistentVolumeClaims:
+    alter-recovery-bundles-pvc:
+      enabled: true
+      appName: alter
+      spec:
+        storageClassName: cephfs
+        volumeMode: Filesystem
+        accessModes:
+          - ReadWriteMany
+        resources:
+          requests:
+            storage: 30Gi
     graph-20240331-persistent-pvc:
       enabled: false
       appName: graph-grpc-20240331
@@ -2732,13 +2743,6 @@ alter:
       volumeDefinition:
         persistentVolumeClaim:
           claimName: alter-recovery-bundles-pvc
-    volumeClaim:
-      storageClassName: cephfs
-      accessModes:
-        - ReadWriteMany
-      volumeMode: Filesystem
-      name: alter-recovery-bundles-pvc
-      size: 30Gi
 
   inventoryStorageConfigurationRef: remoteROStorageConfiguration
   graphConfigurationRef: alterGraphConfiguration
diff --git a/swh/values/staging/swh-cassandra.yaml b/swh/values/staging/swh-cassandra.yaml
index df8236723..feac9d948 100644
--- a/swh/values/staging/swh-cassandra.yaml
+++ b/swh/values/staging/swh-cassandra.yaml
@@ -2311,14 +2311,6 @@ alter:
       volumeDefinition:
         persistentVolumeClaim:
           claimName: alter-recovery-bundles-pvc
-    volumeClaim:
-      storageClassName: cephfs
-      accessModes:
-        - ReadWriteMany
-      volumeMode: Filesystem
-      name: alter-recovery-bundles-pvc
-      size: 30Gi
-
   inventoryStorageConfigurationRef: cassandraROStorageNoMaskingConfiguration
   graphConfigurationRef: alterGraphConfiguration
   restorationStorageConfigurationRef: rpcRWStorageConfiguration
@@ -2422,6 +2414,17 @@ plainGrpcGraphConfiguration:
 volumes:
   enabled: true
   persistentVolumeClaims:
+    alter-recovery-bundles-pvc:
+      enabled: true
+      appName: alter
+      spec:
+        storageClassName: cephfs
+        volumeMode: Filesystem
+        accessModes:
+          - ReadWriteMany
+        resources:
+          requests:
+            storage: 30Gi
     graph-python3k-persistent-pvc:
       enabled: true
       appName: graph-grpc-python3k
-- 
GitLab


From 87f937e63692e48353e027cdd68948c0075d0954 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 13:48:05 +0100
Subject: [PATCH 07/12] local-cluster/objstorage: Share pvc amongst
 objstorage-ro/rw instances

Refs. swh/infra/sysadm-environment#5593
---
 swh/values/local-cluster.yaml | 36 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/swh/values/local-cluster.yaml b/swh/values/local-cluster.yaml
index 3bfed62bd..c3c8a8324 100644
--- a/swh/values/local-cluster.yaml
+++ b/swh/values/local-cluster.yaml
@@ -1292,18 +1292,8 @@ objstorage:
         pathslicing-rw:
           mountPath: /srv/swh/objects
           volumeDefinition:
-            ephemeral:
-              volumeClaimTemplate:
-                metadata:
-                  labels:
-                    type: persistent-volume
-                spec:
-                  accessModes:
-                  - ReadWriteOnce
-                  resources:
-                    requests:
-                      storage: 1Gi
-                  storageClassName: standard
+            persistentVolumeClaim:
+              claimName: objstorage-pathslicing-pvc
 
       # mandatory
       # check readWriteStorageConfiguration example to configure your storage
@@ -1318,18 +1308,8 @@ objstorage:
           mountPath: /srv/swh/objects
           readOnly: true
           volumeDefinition:
-            ephemeral:
-              volumeClaimTemplate:
-                metadata:
-                  labels:
-                    type: persistent-volume
-                spec:
-                  accessModes:
-                  - ReadWriteOnce
-                  resources:
-                    requests:
-                      storage: 1Gi
-                  storageClassName: standard
+            persistentVolumeClaim:
+              claimName: objstorage-pathslicing-pvc
 
       # mandatory
       # check readWriteStorageConfiguration example to configure your storage
@@ -1589,6 +1569,14 @@ volumes:
         resources:
           requests:
             storage: 1Gi
+    objstorage-pathslicing-pvc:
+      spec:
+        accessModes:
+        - ReadWriteOnce
+        resources:
+          requests:
+            storage: 1Gi
+        storageClassName: standard
 
 graph:
   enabled: false
-- 
GitLab


From 2716bcdd5caf84866054016a571f14dbb2c1eedf Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 13:48:12 +0100
Subject: [PATCH 08/12] next-version/objstorage: Share pvc amongst
 objstorage-ro/rw instances

Refs. swh/infra/sysadm-environment#5593
---
 swh/values/staging/next-version.yaml | 43 +++++++++++++++++++---------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/swh/values/staging/next-version.yaml b/swh/values/staging/next-version.yaml
index ddd6a30a6..ac54ca4dd 100644
--- a/swh/values/staging/next-version.yaml
+++ b/swh/values/staging/next-version.yaml
@@ -648,22 +648,23 @@ objstorage:
         pathslicing-rw:
           mountPath: /srv/swh/objects
           volumeDefinition:
-            ephemeral:
-              volumeClaimTemplate:
-                metadata:
-                  labels:
-                    type: persistent-volume
-                spec:
-                  accessModes:
-                  - ReadWriteOnce
-                  resources:
-                    requests:
-                      storage: 10Gi
-                  storageClassName: local-persistent
+            persistentVolumeClaim:
+              claimName: objstorage-pathslicing-pvc
 
       # mandatory
       # check readWriteStorageConfiguration example to configure your storage
       objstorageConfigurationRef: pathslicingRWObjstorageConfiguration
+    ro-pathslicing:
+      enabled: true
+      nodeSelector:
+        kubernetes.io/hostname: rancher-node-staging-rke2-metal01
+      extraVolumes:
+        pathslicing-rw:
+          mountPath: /srv/swh/objects
+          readOnly: true
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: objstorage-pathslicing-pvc
 
       # mandatory
       # check readWriteStorageConfiguration example to configure your storage
@@ -679,10 +680,14 @@ rwCassandraStorageWithJournalConfiguration:
   journalWriterConfigurationRef: storageJournalWriterConfiguration
   objstorageConfigurationRef: rpcRWObjstoragePathslicingConfiguration
 
+rpcROObjstoragePathslicingConfiguration:
+  cls: remote
+  url: http://objstorage-ro-pathslicing:5003
+  enable_requests_retry: true
+
 roCassandraStorageConfiguration:
   storageConfigurationRef: roCassandraStorage
-  # TODO: Use a RO objstorage
-  objstorageConfigurationRef: rpcRWObjstoragePathslicingConfiguration
+  objstorageConfigurationRef: rpcROObjstoragePathslicingConfiguration
 
 rwCassandraStorageForReferenceTableJob:
   <<: *rwCassandraStorage
@@ -1265,6 +1270,16 @@ plainGrpcGraphConfiguration:
 volumes:
   enabled: true
   persistentVolumeClaims:
+    objstorage-pathslicing-pvc:
+      enabled: true
+      spec:
+        storageClassName: local-persistent
+        volumeMode: Filesystem
+        accessModes:
+          - ReadWriteMany
+        resources:
+          requests:
+            storage: 10Gi
     swh-graph-grpc-dataset-example-pvc:
       enabled: true
       appName: graph-grpc-example
-- 
GitLab


From d57cee5cecbb4f5c01595ba4cef19cef5baf61a3 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 13:53:39 +0100
Subject: [PATCH 09/12] graph: Allow volumeDefinition declaration

As objstorage, alter, etc... does

Refs. swh/infra/sysadm-environment#5593
---
 swh/templates/graph/deployment.yaml | 7 ++++++-
 swh/values/local-cluster.yaml       | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/swh/templates/graph/deployment.yaml b/swh/templates/graph/deployment.yaml
index b21a1fe34..d5c13a1e1 100644
--- a/swh/templates/graph/deployment.yaml
+++ b/swh/templates/graph/deployment.yaml
@@ -219,10 +219,15 @@ spec:
           name: backend-utils
           defaultMode: 0555
       {{- range $volumeName, $volumeConfig := $graphConfig.extraVolumes }}
-      {{- $pvcName := $volumeConfig.pvcName | default (print $volumeName "-pvc") }}
+      {{- $pvcName := $volumeConfig.pvcName }}
       - name: {{ $volumeName }}
+        {{- if $pvcName }}
         persistentVolumeClaim:
           claimName: {{ $pvcName }}
+        {{- end }}
+        {{- if $volumeConfig.volumeDefinition }}
+        {{- toYaml $volumeConfig.volumeDefinition | nindent 8 }}
+        {{- end }}
       {{ end }}
 {{ end }}
 {{ end -}}
diff --git a/swh/values/local-cluster.yaml b/swh/values/local-cluster.yaml
index c3c8a8324..966afc54a 100644
--- a/swh/values/local-cluster.yaml
+++ b/swh/values/local-cluster.yaml
@@ -1618,7 +1618,9 @@ graph:
         # in-memory volumes
         graph-example-inmemory:
           mountPath: /srv/graph
-          pvcName: graph-example-inmemory-pvc
+          volumeDefinition:
+            persistentVolumeClaimName:
+              claimName: graph-example-inmemory-pvc
       hosts:
         - graph-grpc-example-ingress
       ingress:
-- 
GitLab


From 790b4bd18e0ddf7cc98378188c51b34b469ab419 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 16:21:53 +0100
Subject: [PATCH 10/12] graph: Align deployment with other deployment regarding
 volumeDefinition

As in objstorage, alter, etc...

Refs. swh/infra/sysadm-environment#5593
---
 swh/templates/graph/deployment.yaml      |  6 ------
 swh/values/local-cluster.yaml            | 14 ++++++++++----
 swh/values/production/swh-cassandra.yaml | 17 ++++++++++++-----
 swh/values/staging/next-version.yaml     |  9 ++++++---
 swh/values/staging/swh-cassandra.yaml    |  8 ++++++--
 5 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/swh/templates/graph/deployment.yaml b/swh/templates/graph/deployment.yaml
index d5c13a1e1..0641f5602 100644
--- a/swh/templates/graph/deployment.yaml
+++ b/swh/templates/graph/deployment.yaml
@@ -221,13 +221,7 @@ spec:
       {{- range $volumeName, $volumeConfig := $graphConfig.extraVolumes }}
       {{- $pvcName := $volumeConfig.pvcName }}
       - name: {{ $volumeName }}
-        {{- if $pvcName }}
-        persistentVolumeClaim:
-          claimName: {{ $pvcName }}
-        {{- end }}
-        {{- if $volumeConfig.volumeDefinition }}
         {{- toYaml $volumeConfig.volumeDefinition | nindent 8 }}
-        {{- end }}
       {{ end }}
 {{ end }}
 {{ end -}}
diff --git a/swh/values/local-cluster.yaml b/swh/values/local-cluster.yaml
index 966afc54a..dfc7b8077 100644
--- a/swh/values/local-cluster.yaml
+++ b/swh/values/local-cluster.yaml
@@ -1614,12 +1614,14 @@ graph:
         # persistent volume
         grpc-example-dataset-example:
           mountPath: /srv/dataset
-          pvcName: grpc-example-dataset-example-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: grpc-example-dataset-example-pvc
         # in-memory volumes
         graph-example-inmemory:
           mountPath: /srv/graph
           volumeDefinition:
-            persistentVolumeClaimName:
+            persistentVolumeClaim:
               claimName: graph-example-inmemory-pvc
       hosts:
         - graph-grpc-example-ingress
@@ -1673,11 +1675,15 @@ graph:
       extraVolumes:
         graph-popular-persistent:
           mountPath: /srv/dataset
-          pvcName: graph-popular-persistent-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-popular-persistent-pvc
         # in-memory volumes
         graph-popular-inmemory:
           mountPath: /srv/graph
-          pvcName: graph-popular-inmemory-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-popular-inmemory-pvc
       hosts:
         - graph-grpc-popular-ingress
       ingress:
diff --git a/swh/values/production/swh-cassandra.yaml b/swh/values/production/swh-cassandra.yaml
index 85b2763dd..9f7585683 100644
--- a/swh/values/production/swh-cassandra.yaml
+++ b/swh/values/production/swh-cassandra.yaml
@@ -2625,12 +2625,15 @@ graph:
       extraVolumes:
         graph-20240331-persistent:
           mountPath: /srv/dataset/2024-03-31/compressed
-          pvcName: graph-20240331-persistent-pvc
-
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-20240331-persistent-pvc
         # in-memory volumes
         graph-20240331-inmemory:
           mountPath: /srv/graph
-          pvcName: graph-20240331-inmemory-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-20240331-inmemory-pvc
       hosts:
         - graph-grpc-20240331-ingress
       ingress:
@@ -2684,11 +2687,15 @@ graph:
       extraVolumes:
         graph-20241206-persistent:
           mountPath: /srv/dataset/2024-12-06/compressed
-          pvcName: graph-20241206-persistent-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-20241206-persistent-pvc
         # in-memory volumes
         graph-20241206-inmemory:
           mountPath: /srv/graph
-          pvcName: graph-20241206-inmemory-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-20241206-inmemory-pvc
       hosts:
         - graph-grpc.internal.softwareheritage.org
         - graph-grpc-20241206-ingress
diff --git a/swh/values/staging/next-version.yaml b/swh/values/staging/next-version.yaml
index ac54ca4dd..b577655e1 100644
--- a/swh/values/staging/next-version.yaml
+++ b/swh/values/staging/next-version.yaml
@@ -650,7 +650,6 @@ objstorage:
           volumeDefinition:
             persistentVolumeClaim:
               claimName: objstorage-pathslicing-pvc
-
       # mandatory
       # check readWriteStorageConfiguration example to configure your storage
       objstorageConfigurationRef: pathslicingRWObjstorageConfiguration
@@ -1327,12 +1326,16 @@ graph:
         # persistent volume (where the full dataset files are stored)
         swh-graph-grpc-dataset-example:
           mountPath: /srv/dataset
-          pvcName: swh-graph-grpc-dataset-example-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: swh-graph-grpc-dataset-example-pvc
         # in-memory volume (where the *.graph files and links to the files in persistent
         # volume are)
         swh-graph-grpc-inmemory:
           mountPath: /srv/graph
-          pvcName: swh-graph-grpc-inmemory-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: swh-graph-grpc-inmemory-pvc
       hosts:
         - graph-grpc-next-version.internal.staging.swh.network
         - graph-grpc-next-version-ingress
diff --git a/swh/values/staging/swh-cassandra.yaml b/swh/values/staging/swh-cassandra.yaml
index feac9d948..a5668ed9d 100644
--- a/swh/values/staging/swh-cassandra.yaml
+++ b/swh/values/staging/swh-cassandra.yaml
@@ -2469,11 +2469,15 @@ graph:
       extraVolumes:
         graph-python3k-persistent:
           mountPath: /srv/dataset
-          pvcName: graph-python3k-persistent-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-python3k-persistent-pvc
         # in-memory volumes
         graph-python3k-inmemory:
           mountPath: /srv/graph
-          pvcName: graph-python3k-inmemory-pvc
+          volumeDefinition:
+            persistentVolumeClaim:
+              claimName: graph-python3k-inmemory-pvc
       hosts:
         - graph-grpc.internal.staging.swh.network
         - graph-grpc-ingress
-- 
GitLab


From bc5b1acfeb22a442775eec8ad9e1a7dc767d7b07 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Fri, 7 Mar 2025 16:53:12 +0100
Subject: [PATCH 11/12] cluster-components: Support global pv and pvc
 management on helm charts

Add one objstorage-pathslicing-pvc to manage the next-version objstorage.
That way, the data stored won't get decommissionned when the argocd
next-version is stopped.

Refs. swh/infra/sysadm-environment#5593
---
 .../volumes/persistent-volume-claims.yaml     | 18 +++++++
 .../templates/volumes/persistent-volume.yaml  | 18 +++++++
 cluster-components/values.yaml                | 54 +++++++++++++++++++
 .../values/archive-staging-rke2.yaml          | 14 +++++
 swh/values.yaml                               |  1 -
 swh/values/staging/next-version.yaml          | 10 ----
 6 files changed, 104 insertions(+), 11 deletions(-)
 create mode 100644 cluster-components/templates/volumes/persistent-volume-claims.yaml
 create mode 100644 cluster-components/templates/volumes/persistent-volume.yaml

diff --git a/cluster-components/templates/volumes/persistent-volume-claims.yaml b/cluster-components/templates/volumes/persistent-volume-claims.yaml
new file mode 100644
index 000000000..26716fb49
--- /dev/null
+++ b/cluster-components/templates/volumes/persistent-volume-claims.yaml
@@ -0,0 +1,18 @@
+{{- range $pvcName, $pvcConfig := .Values.volumes.persistentVolumeClaims }}
+{{- if or (not (hasKey $pvcConfig "enabled")) (get $pvcConfig "enabled") -}}
+{{- $namespace := $pvcConfig.namespace | default $.Values.namespace -}}
+{{- $appName := $pvcConfig.appName -}}
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: {{ $pvcName }}
+  namespace: {{ $namespace }}
+  {{- if $appName }}
+  labels:
+    app: {{ $appName }}
+  {{- end }}
+spec:
+  {{- toYaml $pvcConfig.spec | nindent 2 }}
+{{ end }}
+{{ end }}
diff --git a/cluster-components/templates/volumes/persistent-volume.yaml b/cluster-components/templates/volumes/persistent-volume.yaml
new file mode 100644
index 000000000..44bec08c7
--- /dev/null
+++ b/cluster-components/templates/volumes/persistent-volume.yaml
@@ -0,0 +1,18 @@
+{{- range $pvName, $pvConfig := .Values.volumes.persistentVolumes }}
+{{- if or (not (hasKey $pvConfig "enabled")) (get $pvConfig "enabled") -}}
+{{- $namespace := $pvConfig.namespace | default $.Values.namespace -}}
+{{- $appName := $pvConfig.appName -}}
+---
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: {{ $pvName }}
+  namespace: {{ $namespace }}
+  {{- if $appName }}
+  labels:
+    app: {{ $appName }}
+  {{- end }}
+spec:
+  {{- toYaml $pvConfig.spec | nindent 2 }}
+{{ end }}
+{{ end }}
diff --git a/cluster-components/values.yaml b/cluster-components/values.yaml
index 650a5e35c..2d2f90eb3 100644
--- a/cluster-components/values.yaml
+++ b/cluster-components/values.yaml
@@ -533,3 +533,57 @@ redis:
   #     # [optional] Application name override (e.g. to call it "redis" for example)
   #     # appName: redis
   #     replicas: 3
+
+volumes:
+  # Where to declare the pvs and pvcs (can be overridden per instance)
+  # namespace: swh
+  # Dictionary of persistent volumes specification
+  persistentVolumes: {}
+    # Dictionary of persistent volumes specification
+    # graph-20240331-persistent-local-pv:
+    #   # Can be disabled, enabled by default if not provided
+    #   enabled: true
+    #   # namespace: swh-cassandra
+    #   # The pv's specification, this is the raw yaml supported by kubernetes
+    #   spec:
+    #     capacity:
+    #       storage: 1Gi
+    #     volumeMode: Filesystem
+    #     accessModes:
+    #     - ReadWriteOnce
+    #     persistentVolumeReclaimPolicy: Retain
+    #     storageClassName: local-storage
+    #     local:
+    #       path: /srv/softwareheritage/ssd/graph/2024-03-31/compressed
+    #     nodeAffinity:
+    #       required:
+    #         nodeSelectorTerms:
+    #         - matchExpressions:
+    #           - key: kubernetes.io/hostname
+    #             operator: In
+    #             values: rancher-node-highmem02
+  # Dictionary of persistent volume claims specification
+  persistentVolumeClaims: {}
+    # graph-20240331-persistent-pvc:
+    #   enabled: true
+    #   # optional application name to whom this pv is associated
+    #   appName: graph-20240331
+    #   spec:
+    #     storageClassName: local-storage
+    #     volumeMode: Filesystem
+    #     volumeName: graph-20240331-persistent-pv
+    #     accessModes:
+    #     - ReadWriteOnce
+    #     resources:
+    #       requests:
+    #         storage: 1Gi
+    # graph-20240331-inmemory-pvc:
+    #   enabled: true
+    #   spec:
+    #     storageClassName: local-path
+    #     volumeMode: Filesystem
+    #     accessModes:
+    #     - ReadWriteOnce
+    #     resources:
+    #       requests:
+    #         storage: 1Gi
diff --git a/cluster-components/values/archive-staging-rke2.yaml b/cluster-components/values/archive-staging-rke2.yaml
index 5a93205d3..8a6ac3e66 100644
--- a/cluster-components/values/archive-staging-rke2.yaml
+++ b/cluster-components/values/archive-staging-rke2.yaml
@@ -568,3 +568,17 @@ redis:
               requests:
                 storage: 1Gi
 
+volumes:
+  persistentVolumeClaims:
+    objstorage-pathslicing-pvc:
+      enabled: true
+      namespace: swh-cassandra-next-version
+      spec:
+        storageClassName: local-persistent
+        volumeMode: Filesystem
+        accessModes:
+          - ReadWriteMany
+        resources:
+          requests:
+            storage: 10Gi
+
diff --git a/swh/values.yaml b/swh/values.yaml
index e74f3d059..d57a80267 100644
--- a/swh/values.yaml
+++ b/swh/values.yaml
@@ -2067,4 +2067,3 @@ graph:
     #       default:
     #         paths:
     #           - path: /
-
diff --git a/swh/values/staging/next-version.yaml b/swh/values/staging/next-version.yaml
index b577655e1..2fb467001 100644
--- a/swh/values/staging/next-version.yaml
+++ b/swh/values/staging/next-version.yaml
@@ -1269,16 +1269,6 @@ plainGrpcGraphConfiguration:
 volumes:
   enabled: true
   persistentVolumeClaims:
-    objstorage-pathslicing-pvc:
-      enabled: true
-      spec:
-        storageClassName: local-persistent
-        volumeMode: Filesystem
-        accessModes:
-          - ReadWriteMany
-        resources:
-          requests:
-            storage: 10Gi
     swh-graph-grpc-dataset-example-pvc:
       enabled: true
       appName: graph-grpc-example
-- 
GitLab


From 057e4e151a4a5ed91adfe0f6aaad9b8772cea886 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Mon, 10 Mar 2025 17:45:07 +0100
Subject: [PATCH 12/12] persistent-volume: Drop spurious namespace entry

PV does not declare namespace.

Refs. swh/infra/sysadm-environment#5593
---
 cluster-components/templates/volumes/persistent-volume.yaml | 2 --
 swh/templates/volumes/persistent-volume.yaml                | 2 --
 2 files changed, 4 deletions(-)

diff --git a/cluster-components/templates/volumes/persistent-volume.yaml b/cluster-components/templates/volumes/persistent-volume.yaml
index 44bec08c7..1d0f8db90 100644
--- a/cluster-components/templates/volumes/persistent-volume.yaml
+++ b/cluster-components/templates/volumes/persistent-volume.yaml
@@ -1,13 +1,11 @@
 {{- range $pvName, $pvConfig := .Values.volumes.persistentVolumes }}
 {{- if or (not (hasKey $pvConfig "enabled")) (get $pvConfig "enabled") -}}
-{{- $namespace := $pvConfig.namespace | default $.Values.namespace -}}
 {{- $appName := $pvConfig.appName -}}
 ---
 apiVersion: v1
 kind: PersistentVolume
 metadata:
   name: {{ $pvName }}
-  namespace: {{ $namespace }}
   {{- if $appName }}
   labels:
     app: {{ $appName }}
diff --git a/swh/templates/volumes/persistent-volume.yaml b/swh/templates/volumes/persistent-volume.yaml
index a7ea1affc..2f72f8e17 100644
--- a/swh/templates/volumes/persistent-volume.yaml
+++ b/swh/templates/volumes/persistent-volume.yaml
@@ -1,14 +1,12 @@
 {{ if .Values.volumes.enabled -}}
 {{- range $pvName, $pvConfig := .Values.volumes.persistentVolumes }}
 {{- if or (not (hasKey $pvConfig "enabled")) (get $pvConfig "enabled") -}}
-{{- $namespace := $pvConfig.namespace | default $.Values.namespace -}}
 {{- $appName := $pvConfig.appName -}}
 ---
 apiVersion: v1
 kind: PersistentVolume
 metadata:
   name: {{ $pvName }}
-  namespace: {{ $namespace }}
   {{- if $appName }}
   labels:
     app: {{ $appName }}
-- 
GitLab