diff --git a/swh/templates/storage/configmap.yaml b/swh/templates/storage/configmap.yaml index 21a6e48901affe7b7fd649e1fd1aaf1ad166e1ad..1c32e5440737ecbe803c5d28ab25bd127872fde7 100644 --- a/swh/templates/storage/configmap.yaml +++ b/swh/templates/storage/configmap.yaml @@ -9,12 +9,16 @@ data: config.yml.template: | storage: cls: {{ .Values.storage.storageClass }} + {{- if eq .Values.storage.storageClass "cassandra" }} hosts: - {{- range $seed := .Values.storage.cassandra.seeds }} + {{- range $seed := .Values.storage.cassandra.seeds }} - {{ $seed }} - {{- end }} + {{- end }} keyspace: {{ .Values.storage.cassandra.keySpace }} consistency_level: {{ .Values.storage.cassandra.consistencyLevel }} + {{- else if eq .Values.storage.storageClass "postgresql" }} + db: host={{ .Values.storage.postgresql.host }} port={{ .Values.storage.postgresql.port | default "5432" }} user={{ .Values.storage.postgresql.user | default "guest" }} dbname={{ .Values.storage.postgresql.db | default "swh" }} password=${POSTGRESQL_PASSWORD} + {{- end }} {{- if .Values.storage.specific_options -}} {{- range $option, $value := .Values.storage.specific_options }} {{ $option }}: {{ $value }} diff --git a/swh/templates/storage/deployment.yaml b/swh/templates/storage/deployment.yaml index 13729abe87e364138a68c17f812db723058f7ad8..7701ca9f32fe94a3817c4dc0eb4bce52fc7bbd8e 100644 --- a/swh/templates/storage/deployment.yaml +++ b/swh/templates/storage/deployment.yaml @@ -37,12 +37,23 @@ spec: args: - -c - eval echo "\"$(</etc/swh/configuration-template/config.yml.template)\"" > /etc/swh/config.yml + {{- if eq .Values.storage.storageClass "postgresql" }} + env: + - name: POSTGRESQL_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.storage.postgresql.secretKeyRef }} + key: {{ .Values.storage.postgresql.secretKeyName }} + # 'name' secret must exist & include that ^ key + optional: false + {{- end }} volumeMounts: - name: configuration mountPath: /etc/swh - name: configuration-template mountPath: /etc/swh/configuration-template - {{- if .Values.storage.cassandra.initKeyspace }} + {{- if eq .Values.storage.storageClass "cassandra" }} + {{- if .Values.storage.cassandra.initKeyspace }} - name: init-database image: {{ .Values.swh_storage_image }}:{{ .Values.swh_storage_image_version }} imagePullPolicy: Always @@ -51,6 +62,7 @@ spec: args: - -c - eval "echo \"from swh.storage.cassandra import create_keyspace; create_keyspace(['{{ first .Values.storage.cassandra.seeds }}'], 'swh')\" | python3" + {{- end }} {{- end }} containers: - name: storage diff --git a/swh/templates/storage/service.yaml b/swh/templates/storage/service.yaml index c11cacbbd1e71a265a636a27df2f11385016f98f..482800f281229753aec4dafb4039ab1f1d993ace 100644 --- a/swh/templates/storage/service.yaml +++ b/swh/templates/storage/service.yaml @@ -12,4 +12,5 @@ spec: ports: - port: 5002 targetPort: 5002 + name: rpc {{ end }} diff --git a/swh/values.yaml b/swh/values.yaml index afdeec9fcfd89ff45197e0bf03c1af845b9a98c7..327fe90a825d407cebe2af828cb8743106935141 100644 --- a/swh/values.yaml +++ b/swh/values.yaml @@ -167,7 +167,6 @@ storage: requestedMemory: 100Mi autoScaling: maxReplicaCount: 1 - storageClass: cassandra # affinity: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -188,12 +187,24 @@ storage: # like https://token@sentry.host/id secretKeyRef: common-secrets secretKeyName: storage-sentry-dsn - cassandra: - initKeyspace: false # only to bootstrap a new cassandra database - seeds: - - seed1 - keySpace: swh - consistencyLevel: LOCAL_QUORUM + # Mandatory: must be 'postgresql' or 'cassandra' + storageClass: + # if storageClass is 'cassandra' + # cassandra: + # initKeyspace: false # only to bootstrap a new cassandra database + # seeds: + # - seed1 + # keySpace: swh + # consistencyLevel: LOCAL_QUORUM + # if storageClass is 'postgresql' + # postgresql: + # host: postgresql + # port: 5432 + # db: softwareheritage + # user: guest + # # name of the secret containing the $secretKeyName value + # secretKeyRef: common-secrets + # secretKeyName: storage-postgresql-password objstorage: cls: noop diff --git a/swh/values/staging-cassandra.yaml b/swh/values/staging-cassandra.yaml index 4f0f9229d4919a7dc97a5232f75e0e7cd956110f..6b318f57b0ad8f11b4d9fb2c96a915a5699801ee 100644 --- a/swh/values/staging-cassandra.yaml +++ b/swh/values/staging-cassandra.yaml @@ -183,4 +183,13 @@ storage: seeds: - cassandra1.internal.staging.swh.network - cassandra2.internal.staging.swh.network - - cassandra3.internal.staging.swh.network \ No newline at end of file + - cassandra3.internal.staging.swh.network + keySpace: swh + consistencyLevel: LOCAL_QUORUM + objstorage: + cls: filtered + storage_conf: + cls: remote + url: http://storage1.internal.staging.swh.network:5003/ + filters_conf: + - type: readonly \ No newline at end of file