From 39e6c64e3de0672418694797b4a1370d3313b806 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Tue, 28 Nov 2023 17:07:45 +0100
Subject: [PATCH] minikube: Allow objstorage service to run

Refs. swh/infra/sysadm-environment#5164
---
 Makefile                 |  4 ++--
 swh/fake-volumes/pv.yaml | 27 +++++++++++++++++++++++
 swh/values/minikube.yaml | 47 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+), 2 deletions(-)
 create mode 100644 swh/fake-volumes/pv.yaml

diff --git a/Makefile b/Makefile
index 76d82cd89..c0534664b 100644
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,7 @@ helm-diff: swh-helm-diff ccf-helm-diff cc-helm-diff ss-helm-diff
 
 swh-minikube:
 	kubectl --context minikube create namespace swh ; \
-	kubectl --context minikube --namespace swh apply -f '$(SWH_CHART)/fake-secrets/*.yaml' ; \
+	kubectl --context minikube --namespace swh apply -f '$(SWH_CHART)/fake-secrets/*.yaml' -f '$(SWH_CHART)/fake-volumes/*.yaml' ; \
 	helm --kube-context minikube upgrade --install $(SWH_CHART) $(SWH_CHART)/ --values values-swh-application-versions.yaml \
       --values $(SWH_CHART)/values.yaml \
       --values $(SWH_CHART)/values/minikube.yaml \
@@ -50,7 +50,7 @@ swh-minikube:
 
 swh-uninstall:
 	helm --kube-context minikube uninstall $(SWH_CHART) -n swh ; \
-    kubectl --context minikube --namespace swh delete -f '$(SWH_CHART)/fake-secrets/*.yaml'; \
+    kubectl --context minikube --namespace swh delete -f '$(SWH_CHART)/fake-secrets/*.yaml'  -f '$(SWH_CHART)/fake-volumes/*.yaml' ; \
 	kubectl --context minikube delete namespace swh
 
 swh-template:
diff --git a/swh/fake-volumes/pv.yaml b/swh/fake-volumes/pv.yaml
new file mode 100644
index 000000000..1bc1a9830
--- /dev/null
+++ b/swh/fake-volumes/pv.yaml
@@ -0,0 +1,27 @@
+---
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: minikube-pathslicing-pv
+  labels:
+    type: local
+spec:
+  storageClassName: local-persistent
+  capacity:
+    storage: 10Gi
+  accessModes:
+    - ReadWriteOnce
+  hostPath:
+    path: "/srv/swh/objects"
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: minikube-pathslicing-pv-claim
+spec:
+  storageClassName: local-persistent
+  accessModes:
+    - ReadWriteOnce
+  resources:
+    requests:
+      storage: 10Gi
diff --git a/swh/values/minikube.yaml b/swh/values/minikube.yaml
index 7aef2cd98..b93965607 100644
--- a/swh/values/minikube.yaml
+++ b/swh/values/minikube.yaml
@@ -839,3 +839,50 @@ scrubber:
         journalClientOverrides:
           batch_size: 200
         object: release
+
+fakeObjstorageConfiguration:
+  cls: pathslicing
+  root: "/srv/swh/objects"
+  slicing: 0:1/1:5
+  client_max_size: 1073741824
+
+objstorage:
+  enabled: false
+  port: 5003
+  priorityClassName: frontend-rpc
+  deployments:
+    # Each key will be an objstorage instance to be deployed
+    # The mandatory objstorageConfigurationRef key should target a dict
+    # with the specific objstorage configuration
+    read-write:
+      enabled: true
+      logLevel: INFO
+      requestedCpu: 50m
+      requestedMemory: 100Mi
+      gunicorn:
+        threads: 5
+        workers: 2
+        timeout: 60
+      replicas: 1
+      volumes:
+        minikube-pathslicing-pv:
+          # See k8s-cluster-config for such pvc declaration
+          persistentVolumeClaim: minikube-pathslicing-pv-claim
+          mountPath: /srv/swh/objects
+
+      # mandatory
+      # check readWriteStorageConfiguration example to configure your storage
+      objstorageConfigurationRef: fakeObjstorageConfiguration
+        # Deploy an ingress to access the objstorage
+      hosts:
+        - objstorage.s.s.n
+      ingress:
+        enabled: false
+        # mandatory if ingress is enabled
+        # the hostname on which the objstorage must be reachable
+        # Optional: the ingress classname to use
+        className: nginx
+        endpoints:
+          default:
+            paths:
+              - path: /
-- 
GitLab