Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ Return the Database Secret Name
{{- end -}}
{{- end -}}

{{/*
Return the image for the wait-for-db init container.
Defaults to the PostgreSQL subchart image.
*/}}
{{- define "sequin.waitForDB.image" -}}
{{- include "common.images.image" (dict "imageRoot" .Values.postgresql.image "global" .Values.global) -}}
{{- end -}}

{{/*
Get the Redis® fullname
*/}}
Expand Down
24 changes: 23 additions & 1 deletion templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,31 @@ spec:
{{- if .Values.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.initContainers }}
{{- if or (and .Values.waitForDB.enabled .Values.postgresql.enabled) .Values.initContainers }}
initContainers:
{{- if and .Values.waitForDB.enabled .Values.postgresql.enabled }}
- name: wait-for-db
image: {{ include "sequin.waitForDB.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
command:
- /bin/bash
- -ec
- |
host={{ include "sequin.database.host" . | quote }}
port={{ include "sequin.database.port" . | quote }}
user={{ include "sequin.database.username" . | quote }}
echo "Waiting for PostgreSQL at ${host}:${port}..."
until pg_isready -h "$host" -p "$port" -U "$user" -q; do
sleep 2
done
echo "PostgreSQL is accepting connections"
{{- end }}
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
{{- end }}
{{- end }}
containers:
- name: sequin
Expand Down
12 changes: 12 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,18 @@ sidecars: []
## command: ['sh', '-c', 'echo "hello world"']
##
initContainers: []
## @section Database readiness parameters
##

## Wait for database init container
## Adds an init container that waits for PostgreSQL to accept connections
## before starting Sequin. Prevents crash-loops on fresh installs when
## deploying with the bundled PostgreSQL subchart.
## Only takes effect when postgresql.enabled=true.
## @param waitForDB.enabled Enable the wait-for-db init container
##
waitForDB:
enabled: true
## @section Traffic Exposure Parameters
##

Expand Down