matrix-synapse: Add persistence

This commit is contained in:
Alexander Olofsson 2020-08-08 20:38:36 +02:00
parent 5917a8eefc
commit 414338d47a
No known key found for this signature in database
GPG key ID: D439C9470CB04C73
5 changed files with 67 additions and 10 deletions

View file

@ -90,6 +90,8 @@ spec:
mountPath: /synapse/secrets mountPath: /synapse/secrets
- name: signingkey - name: signingkey
mountPath: /synapse/keys mountPath: /synapse/keys
- name: media
mountPath: /synapse/data
resources: resources:
{{- toYaml .Values.resources | nindent 12 }} {{- toYaml .Values.resources | nindent 12 }}
volumes: volumes:
@ -107,6 +109,20 @@ spec:
path: signing.key path: signing.key
- name: tmpconf - name: tmpconf
emptyDir: {} emptyDir: {}
- name: media
{{- $mediaworker := false }}
{{- range $worker, $config := .Values.workers }}
{{- if eq $worker "media-repository" }}
{{- $mediaworker = true }}
{{- end }}
{{- end }}
{{- if and .Values.persistence.enabled (not $mediaworker) }}
persistentVolumeClaim:
claimName: {{ default .Values.persistence.existingClaim (include "matrix-synapse.fullname" .) }}
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
@ -236,8 +252,12 @@ spec:
emptyDir: {} emptyDir: {}
{{- if eq $name "media-repository" }} {{- if eq $name "media-repository" }}
- name: media - name: media
{{- if $.Values.persistence.enabled }}
persistentVolumeClaim: persistentVolumeClaim:
claimName: claimName: {{ default $.Values.persistence.existingClaim (include "matrix-synapse.fullname" $) }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }} {{- end }}
{{- with $config.volumes }} {{- with $config.volumes }}
{{ . | toYaml | nindent 8 }} {{ . | toYaml | nindent 8 }}

View file

@ -27,10 +27,9 @@ spec:
{{- end }} {{- end }}
{{- end }} {{- end }}
rules: rules:
{{- $hosts := .Values.ingress.hosts }}
{{- if default .Values.ingress.includeServerName true }} {{- if default .Values.ingress.includeServerName true }}
{{- $hosts := concat (list .Values.config.serverName) .Values.ingress.hosts }} {{- $hosts = concat (list .Values.config.serverName) $hosts }}
{{- else }}
{{- $hosts := .Values.ingress.hosts }}
{{- end }} {{- end }}
{{- range $hosts }} {{- range $hosts }}
- host: {{ . | quote }} - host: {{ . | quote }}

View file

@ -0,0 +1,22 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "matrix-synapse.fullname" . }}
labels:
{{- include "matrix-synapse.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end -}}

View file

@ -1,4 +1,7 @@
{{- if and .Values.signingkey.job.enabled (not .Values.signingkey.existingSecret) }} {{- if .Values.signingkey.job.enabled }}
{{- if .Values.signingkey.existingSecret }}
{{- fail "Can't specify both signingkey.job.enabled and signingkey.existingSecret" }}
{{- end }}
{{- $name := include "matrix-synapse.workername" (dict "global" . "worker" "signingkey-job") }} {{- $name := include "matrix-synapse.workername" (dict "global" . "worker" "signingkey-job") }}
--- ---
apiVersion: v1 apiVersion: v1
@ -46,6 +49,7 @@ metadata:
component: job component: job
job: signing-key-generation job: signing-key-generation
spec: spec:
ttlSecondsAfterFinished: 0
template: template:
metadata: metadata:
labels: labels:
@ -67,8 +71,8 @@ spec:
name: signing-key-generate name: signing-key-generate
resources: resources:
requests: requests:
memory: 10Mi memory: 25Mi
cpu: 10m cpu: 100m
limits: limits:
memory: 25Mi memory: 25Mi
cpu: 100m cpu: 100m
@ -93,8 +97,8 @@ spec:
name: signing-key-upload name: signing-key-upload
resources: resources:
requests: requests:
memory: 10Mi memory: 50Mi
cpu: 10m cpu: 100m
limits: limits:
memory: 50Mi memory: 50Mi
cpu: 100m cpu: 100m
@ -105,7 +109,6 @@ spec:
- mountPath: /synapse/keys - mountPath: /synapse/keys
name: matrix-synapse-keys name: matrix-synapse-keys
readOnly: true readOnly: true
restartPolicy: Never
serviceAccount: {{ $name }} serviceAccount: {{ $name }}
volumes: volumes:
- name: scripts - name: scripts

View file

@ -110,6 +110,19 @@ externalRedis:
port: 6379 port: 6379
# password: synapse # password: synapse
# Persistence configuration for the media repository.
# This PVC will be mounted in either Synapse or a media_repo worker.
#
# NB; If you want to be able to scale this, you will have to set the
# accessMode to RWX/ReadWriteMany.
persistence:
enabled: true
# existingClaim: synapse-data
# storageClass: "-"
accessMode: ReadWriteOnce
size: 10Gi
# Configuration for handling Synapse workers, which are useful for handling # Configuration for handling Synapse workers, which are useful for handling
# high-load deployments. # high-load deployments.
# More information is available at; # More information is available at;