Skip to content
Snippets Groups Projects
Commit 2ebb31eb 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: ...@@ -9,12 +9,16 @@ data:
config.yml.template: | config.yml.template: |
storage: storage:
cls: {{ .Values.storage.storageClass }} cls: {{ .Values.storage.storageClass }}
{{- if eq .Values.storage.storageClass "cassandra" }}
hosts: hosts:
{{- range $seed := .Values.storage.cassandra.seeds }} {{- range $seed := .Values.storage.cassandra.seeds }}
- {{ $seed }} - {{ $seed }}
{{- end }} {{- end }}
keyspace: {{ .Values.storage.cassandra.keySpace }} keyspace: {{ .Values.storage.cassandra.keySpace }}
consistency_level: {{ .Values.storage.cassandra.consistencyLevel }} 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 -}} {{- if .Values.storage.specific_options -}}
{{- range $option, $value := .Values.storage.specific_options }} {{- range $option, $value := .Values.storage.specific_options }}
{{ $option }}: {{ $value }} {{ $option }}: {{ $value }}
......
...@@ -37,12 +37,23 @@ spec: ...@@ -37,12 +37,23 @@ spec:
args: args:
- -c - -c
- eval echo "\"$(</etc/swh/configuration-template/config.yml.template)\"" > /etc/swh/config.yml - 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: volumeMounts:
- name: configuration - name: configuration
mountPath: /etc/swh mountPath: /etc/swh
- name: configuration-template - name: configuration-template
mountPath: /etc/swh/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 - name: init-database
image: {{ .Values.swh_storage_image }}:{{ .Values.swh_storage_image_version }} image: {{ .Values.swh_storage_image }}:{{ .Values.swh_storage_image_version }}
imagePullPolicy: Always imagePullPolicy: Always
...@@ -51,6 +62,7 @@ spec: ...@@ -51,6 +62,7 @@ spec:
args: args:
- -c - -c
- eval "echo \"from swh.storage.cassandra import create_keyspace; create_keyspace(['{{ first .Values.storage.cassandra.seeds }}'], 'swh')\" | python3" - eval "echo \"from swh.storage.cassandra import create_keyspace; create_keyspace(['{{ first .Values.storage.cassandra.seeds }}'], 'swh')\" | python3"
{{- end }}
{{- end }} {{- end }}
containers: containers:
- name: storage - name: storage
......
...@@ -167,7 +167,6 @@ storage: ...@@ -167,7 +167,6 @@ storage:
requestedMemory: 100Mi requestedMemory: 100Mi
autoScaling: autoScaling:
maxReplicaCount: 1 maxReplicaCount: 1
storageClass: cassandra
# affinity: # affinity:
# nodeAffinity: # nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution: # requiredDuringSchedulingIgnoredDuringExecution:
...@@ -188,12 +187,24 @@ storage: ...@@ -188,12 +187,24 @@ storage:
# like https://token@sentry.host/id # like https://token@sentry.host/id
secretKeyRef: common-secrets secretKeyRef: common-secrets
secretKeyName: storage-sentry-dsn secretKeyName: storage-sentry-dsn
cassandra: # Mandatory: must be 'postgresql' or 'cassandra'
initKeyspace: false # only to bootstrap a new cassandra database storageClass:
seeds: # if storageClass is 'cassandra'
- seed1 # cassandra:
keySpace: swh # initKeyspace: false # only to bootstrap a new cassandra database
consistencyLevel: LOCAL_QUORUM # 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: objstorage:
cls: noop cls: noop
......
...@@ -183,4 +183,13 @@ storage: ...@@ -183,4 +183,13 @@ storage:
seeds: seeds:
- cassandra1.internal.staging.swh.network - cassandra1.internal.staging.swh.network
- cassandra2.internal.staging.swh.network - cassandra2.internal.staging.swh.network
- cassandra3.internal.staging.swh.network - cassandra3.internal.staging.swh.network
\ No newline at end of file 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