{{- if .Values.deployment.realtime.enabled -}} apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "supabase.realtime.fullname" . }} labels: {{- include "supabase.labels" . | nindent 4 }} spec: {{- if not .Values.autoscaling.realtime.enabled }} replicas: {{ .Values.deployment.realtime.replicaCount }} {{- end }} selector: matchLabels: {{- include "supabase.realtime.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.deployment.realtime.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} labels: {{- include "supabase.realtime.selectorLabels" . | nindent 8 }} spec: {{- with .Values.image.realtime.pullSecrets}} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "supabase.realtime.serviceAccountName" . }} securityContext: {{- toYaml .Values.deployment.realtime.podSecurityContext | nindent 8 }} initContainers: - name: init-db image: postgres:15-alpine imagePullPolicy: IfNotPresent env: - name: DB_HOST value: {{ include "supabase.database.host" . | quote }} - name: DB_PORT value: {{ include "supabase.database.port" . | quote }} command: ["/bin/sh", "-c"] args: - | until pg_isready -h $(DB_HOST) -p $(DB_PORT) -U postgres; do echo "Waiting for database to start..." sleep 2 done - echo "Database is ready" containers: - name: {{ include "supabase.realtime.name" $ }} securityContext: {{- toYaml .Values.deployment.realtime.securityContext | nindent 12 }} image: "{{ .Values.image.realtime.repository }}:{{ .Values.image.realtime.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.realtime.pullPolicy }} command: ["/bin/sh"] args: ["-c", "/app/bin/migrate && /app/bin/realtime eval 'Realtime.Release.seeds(Realtime.Repo)' && /app/bin/server"] env: {{- range $key, $value := .Values.environment.realtime }} {{- if and (ne $key "DB_HOST") (ne $key "DB_PORT") (ne $key "DB_SSL") }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} {{- end }} - name: DB_HOST value: {{ include "supabase.database.host" . | quote }} - name: DB_PORT value: {{ include "supabase.database.port" . | quote }} - name: DB_SSL value: {{ ne (include "supabase.database.ssl" .) "disable" | quote }} - name: SELF_HOST_TENANT_NAME value: {{ include "supabase.realtime.fullname" . }} - name: DB_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: DB_NAME 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: JWT_SECRET valueFrom: secretKeyRef: {{- if .Values.secret.jwt.secretRef }} name: {{ .Values.secret.jwt.secretRef }} key: {{ .Values.secret.jwt.secretRefKey.secret | default "secret" }} {{- else }} name: {{ include "supabase.secret.jwt" . }} key: secret {{- end }} - name: API_JWT_SECRET valueFrom: secretKeyRef: {{- if .Values.secret.jwt.secretRef }} name: {{ .Values.secret.jwt.secretRef }} key: {{ .Values.secret.jwt.secretRefKey.secret | default "secret" }} {{- else }} name: {{ include "supabase.secret.jwt" . }} key: secret {{- end }} - name: SECRET_KEY_BASE valueFrom: secretKeyRef: {{- if .Values.secret.realtime.secretRef }} name: {{ .Values.secret.realtime.secretRef }} key: {{ .Values.secret.realtime.secretRefKey.secretKeyBase | default "secretKeyBase" }} {{- else }} name: {{ include "supabase.secret.realtime" . }} key: secretKeyBase {{- end }} {{- with .Values.deployment.realtime.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.deployment.realtime.readinessProbe }} readinessProbe: {{- toYaml . | nindent 12 }} {{- end }} ports: - name: http containerPort: 4000 protocol: TCP {{- with .Values.deployment.realtime.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.deployment.realtime.volumeMounts }} volumeMounts: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.deployment.realtime.volumes }} volumes: {{- toYaml . | nindent 8 }} {{- end }} {{- include "supabase.enforcedGeneralNodeSelector" (dict "nodeSelector" .Values.deployment.realtime.nodeSelector) | nindent 6 }} {{- include "supabase.enforcedGeneralAffinity" (dict "affinity" .Values.deployment.realtime.affinity) | nindent 6 }} {{- with .Values.deployment.realtime.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- end }}