Skip to content
Snippets Groups Projects
Commit ef2eb66a authored by Guillaume Samson's avatar Guillaume Samson
Browse files

storage: support postgresql

Related to swh/infra/sysadm-environment#4811
parent 49e41573
No related branches found
No related tags found
No related merge requests found
......@@ -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 }}
......
......@@ -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
......
......@@ -12,4 +12,5 @@ spec:
ports:
- port: 5002
targetPort: 5002
name: rpc
{{ end }}
......@@ -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
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment