From b0a05c850b152300c94873353c5d4c17738baf63 Mon Sep 17 00:00:00 2001
From: Guillaume Samson <guillaume.samson@softwareheritage.org>
Date: Tue, 28 Mar 2023 18:18:46 +0200
Subject: [PATCH] swh: deploy storage service in staging environment

Related to swh/infra/sysadm-environment#4811
---
 swh/templates/storage/deployment.yaml  |  4 ++--
 swh/tests/storage_deployment_test.yaml |  6 +++---
 swh/values.yaml                        |  2 +-
 swh/values/default.yaml                | 13 +++++++++++++
 swh/values/staging-cassandra.yaml      | 14 ++++++++++++++
 values-swh-application-versions.yaml   |  2 ++
 6 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/swh/templates/storage/deployment.yaml b/swh/templates/storage/deployment.yaml
index 2fb05c916..13729abe8 100644
--- a/swh/templates/storage/deployment.yaml
+++ b/swh/templates/storage/deployment.yaml
@@ -75,7 +75,7 @@ spec:
               path: /
               port: rpc
             initialDelaySeconds: 10
-            periodSeconds: 5          
+            periodSeconds: 5
           command:
           - /bin/bash
           args:
@@ -95,7 +95,7 @@ spec:
             - name: STATSD_PORT
               value: {{ .Values.statsdPort | default "9125" | quote }}
             - name: LOG_LEVEL
-              value: {{ .Values.storage.logLevel | quote }}              
+              value: {{ .Values.storage.logLevel | quote }}
           {{- if .Values.storage.sentry.enabled }}
             - name: SWH_SENTRY_ENVIRONMENT
               value: {{ .Values.sentry.environment }}
diff --git a/swh/tests/storage_deployment_test.yaml b/swh/tests/storage_deployment_test.yaml
index 798fa75de..25cf5a11f 100644
--- a/swh/tests/storage_deployment_test.yaml
+++ b/swh/tests/storage_deployment_test.yaml
@@ -3,7 +3,7 @@ templates:
   - storage/configmap.yaml
   - storage/deployment.yaml
 tests:
-  - it: Storage is deployed 
+  - it: Storage is deployed
     templates:
       - storage/deployment.yaml
     set:
@@ -23,7 +23,7 @@ tests:
           value: 1
       - equal:
           path: spec.template.spec.containers[0].resources.requests.memory
-          value: memory 
+          value: memory
       - equal:
           path: spec.template.spec.containers[0].resources.requests.cpu
           value: cpu
@@ -131,4 +131,4 @@ tests:
           value: my-secret
       - equal:
           path: spec.template.spec.containers[?(@.name == "storage")].env[?(@.name == "SWH_SENTRY_DSN")].valueFrom.secretKeyRef.key
-          value: my-key
\ No newline at end of file
+          value: my-key
diff --git a/swh/values.yaml b/swh/values.yaml
index f2d1e52cf..d35e1b270 100644
--- a/swh/values.yaml
+++ b/swh/values.yaml
@@ -202,7 +202,7 @@ statsd_exporter:
   imageVersion: "v0.22.7"
 
 memcached:
-  # Deploy a memcached instance used by the webapp and storage for sessions caching
+  # Deploy a memcached instance used by the webapp and graphql for sessions caching
   enabled: false
   image: memcached:1.6.18
   memory: 256m
diff --git a/swh/values/default.yaml b/swh/values/default.yaml
index 4084aa19a..50950dea7 100644
--- a/swh/values/default.yaml
+++ b/swh/values/default.yaml
@@ -103,5 +103,18 @@ graphql:
             values:
             - "true"
 
+storage:
+  sentry:
+    enabled: true
+  affinity:
+    nodeAffinity:
+      requiredDuringSchedulingIgnoredDuringExecution:
+        nodeSelectorTerms:
+        - matchExpressions:
+          - key: swh/storage
+            operator: In
+            values:
+            - "true"
+
 statsd_exporter:
   enabled: true
diff --git a/swh/values/staging-cassandra.yaml b/swh/values/staging-cassandra.yaml
index 7d0364657..4f0f9229d 100644
--- a/swh/values/staging-cassandra.yaml
+++ b/swh/values/staging-cassandra.yaml
@@ -170,3 +170,17 @@ storage_replayer:
       #requestedCpu: 80m
       autoScaling:
         maxReplicaCount: 5
+
+storage:
+  enabled: true
+  replicas: 1
+  requestedCpu: 50m
+  requestedMemory: 100Mi
+  autoScaling:
+    maxReplicaCount: 1
+  storageClass: cassandra
+  cassandra:
+    seeds:
+      - cassandra1.internal.staging.swh.network
+      - cassandra2.internal.staging.swh.network
+      - cassandra3.internal.staging.swh.network
\ No newline at end of file
diff --git a/values-swh-application-versions.yaml b/values-swh-application-versions.yaml
index 8e48a52c8..992404fe6 100644
--- a/values-swh-application-versions.yaml
+++ b/values-swh-application-versions.yaml
@@ -22,6 +22,8 @@ swh_loader_package_image: container-registry.softwareheritage.org/swh/infra/swh-
 swh_loader_package_image_version: '20230220.1'
 swh_loader_svn_image: container-registry.softwareheritage.org/swh/infra/swh-apps/loader_svn
 swh_loader_svn_image_version: '20230306.1'
+swh_storage_image: container-registry.softwareheritage.org/swh/infra/swh-apps/storage
+swh_storage_image_version: '20230327.1'
 swh_storage_replayer_image: container-registry.softwareheritage.org/swh/infra/swh-apps/storage_replayer
 swh_storage_replayer_image_version: '20230321.1'
 swh_vault_cookers_image: container-registry.softwareheritage.org/swh/infra/swh-apps/vault_cookers
-- 
GitLab