173 lines
6.6 KiB
YAML
173 lines
6.6 KiB
YAML
{{- if .Values.db.enabled -}}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "supabase.db.fullname" . }}
|
|
labels:
|
|
{{- include "supabase.labels" . | nindent 4 }}
|
|
spec:
|
|
{{- if not .Values.db.autoscaling.enabled }}
|
|
replicas: {{ .Values.db.replicaCount }}
|
|
{{- end }}
|
|
selector:
|
|
matchLabels:
|
|
{{- include "supabase.db.selectorLabels" . | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
{{- with .Values.db.podAnnotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
labels:
|
|
{{- include "supabase.db.selectorLabels" . | nindent 8 }}
|
|
spec:
|
|
{{- with .Values.db.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
serviceAccountName: {{ include "supabase.db.serviceAccountName" . }}
|
|
securityContext:
|
|
{{- toYaml .Values.db.podSecurityContext | nindent 8 }}
|
|
initContainers:
|
|
- name: init-db
|
|
image: "{{ .Values.db.image.repository }}:{{ .Values.db.image.tag | default .Chart.AppVersion }}"
|
|
imagePullPolicy: IfNotPresent
|
|
command: ["/bin/sh", "-c"]
|
|
args:
|
|
- |
|
|
echo "Copying init scripts into existing image script directory..."
|
|
cp -r /docker-entrypoint-initdb.d/* /initdb.d/
|
|
cp /custom-init-scripts/98-webhooks.sql /initdb.d/init-scripts/
|
|
cp /custom-init-scripts/99-roles.sql /initdb.d/init-scripts/
|
|
cp /custom-init-scripts/99-logs.sql /initdb.d/migrations/
|
|
cp /custom-init-scripts/99-realtime.sql /initdb.d/migrations/
|
|
|
|
echo "Copying user-defined migration scripts..."
|
|
cp /custom-migrations/* /initdb.d/migrations/ || echo "Skip migrations"
|
|
echo "Initialization scripts are ready"
|
|
volumeMounts:
|
|
- mountPath: /custom-init-scripts
|
|
name: custom-init-scripts
|
|
- mountPath: /custom-migrations
|
|
name: custom-migrations
|
|
- mountPath: /initdb.d
|
|
name: initdb-scripts-data
|
|
containers:
|
|
- name: {{ include "supabase.db.name" $ }}
|
|
securityContext:
|
|
{{- toYaml .Values.db.securityContext | nindent 12 }}
|
|
image: "{{ .Values.db.image.repository }}:{{ .Values.db.image.tag | default .Chart.AppVersion }}"
|
|
imagePullPolicy: {{ .Values.db.image.pullPolicy }}
|
|
env:
|
|
{{- range $key, $value := .Values.db.environment }}
|
|
- name: {{ $key }}
|
|
value: {{ $value | quote }}
|
|
{{- end }}
|
|
- name: POSTGRES_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
{{- if .Values.secret.db.secretRef }}
|
|
name: {{ .Values.secret.db.secretRef }}
|
|
key: {{ .Values.secret.db.secretRefKey.username | default "username" }}
|
|
{{- else }}
|
|
name: {{ include "supabase.secret.db" . }}
|
|
key: username
|
|
{{- end }}
|
|
- name: PGPASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
{{- if .Values.secret.db.secretRef }}
|
|
name: {{ .Values.secret.db.secretRef }}
|
|
key: {{ .Values.secret.db.secretRefKey.password | default "password" }}
|
|
{{- else }}
|
|
name: {{ include "supabase.secret.db" . }}
|
|
key: password
|
|
{{- end }}
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
{{- if .Values.secret.db.secretRef }}
|
|
name: {{ .Values.secret.db.secretRef }}
|
|
key: {{ .Values.secret.db.secretRefKey.password | default "password" }}
|
|
{{- else }}
|
|
name: {{ include "supabase.secret.db" . }}
|
|
key: password
|
|
{{- end }}
|
|
- name: PGDATABASE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
{{- if .Values.secret.db.secretRef }}
|
|
name: {{ .Values.secret.db.secretRef }}
|
|
key: {{ .Values.secret.db.secretRefKey.database | default "database" }}
|
|
{{- else }}
|
|
name: {{ include "supabase.secret.db" . }}
|
|
key: database
|
|
{{- end }}
|
|
- name: POSTGRES_DB
|
|
valueFrom:
|
|
secretKeyRef:
|
|
{{- if .Values.secret.db.secretRef }}
|
|
name: {{ .Values.secret.db.secretRef }}
|
|
key: {{ .Values.secret.db.secretRefKey.database | default "database" }}
|
|
{{- else }}
|
|
name: {{ include "supabase.secret.db" . }}
|
|
key: database
|
|
{{- end }}
|
|
{{- with .Values.db.livenessProbe }}
|
|
livenessProbe:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- with .Values.db.readinessProbe }}
|
|
readinessProbe:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
ports:
|
|
- name: http
|
|
containerPort: 9999
|
|
protocol: TCP
|
|
volumeMounts:
|
|
- mountPath: /docker-entrypoint-initdb.d
|
|
name: initdb-scripts-data
|
|
{{- with .Values.db.volumeMounts }}
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- if .Values.db.persistence.enabled }}
|
|
- mountPath: /var/lib/postgresql/data
|
|
name: postgres-volume
|
|
subPath: postgres-data
|
|
{{- end }}
|
|
{{- with .Values.db.resources }}
|
|
resources:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
volumes:
|
|
- name: initdb-scripts-data
|
|
emptyDir:
|
|
medium: ""
|
|
- name: custom-init-scripts
|
|
configMap:
|
|
name: {{ include "supabase.db.fullname" . }}-initdb
|
|
- name: custom-migrations
|
|
configMap:
|
|
name: {{ include "supabase.db.fullname" . }}-migrations
|
|
{{- with .Values.db.volumes }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.db.persistence.enabled }}
|
|
- name: postgres-volume
|
|
persistentVolumeClaim:
|
|
claimName: {{ include "supabase.db.fullname" . }}-pvc
|
|
{{- end }}
|
|
{{- with .Values.db.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.db.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.db.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- end }} |