Skip to content

Commit

Permalink
chore: use startupProbe for postgres password reset
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Dec 26, 2024
1 parent a8d82d5 commit 813b20a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
34 changes: 15 additions & 19 deletions chart/templates/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ kind: ConfigMap
metadata:
name: postgresql-scripts
data:
update-admin-password.sh: |
post-startup.sh: |
#!/bin/bash
echo "Updating postgres user password after 60s"
sleep 30
psql -U postgres -c "ALTER USER postgres PASSWORD '${POSTGRES_PASSWORD}';"
---
apiVersion: apps/v1
Expand Down Expand Up @@ -57,29 +55,27 @@ spec:
- name: postgresql
image: {{ tpl .Values.global.imageRegistry . }}/supabase/postgres:14.1.0.89
command:
- /bin/bash
- -c
- |
chmod +x /update-admin-password.sh
# Custom initialization logic
if [ -f /update-admin-password.sh ]; then
echo "Running custom initialization script..."
/bin/bash /update-admin-password.sh &
fi
# Pass control back to the default entrypoint with provided arguments
exec /usr/local/bin/docker-entrypoint.sh -D /var/lib/postgresql/data --config-file=/etc/postgresql/postgresql.conf \
- /usr/local/bin/docker-entrypoint.sh
- -D
- /var/lib/postgresql/data
- --config-file=/etc/postgresql/postgresql.conf
{{- range $k, $v := .Values.db.conf }}
--{{ $k }}={{ $v }} \
- '--{{ $k }}={{ $v }}'
{{- end }}
resources:
{{- toYaml .Values.db.resources | nindent 12 }}
env:
- name: PGDATA
value: /var/lib/postgresql/data
- name: POSTGRES_DB
value: mission_control
startupProbe:
initialDelaySeconds: 15
exec:
command:
- /bin/bash
- -c
- bash /post-startup.sh
volumeMounts:
- name: dshm
mountPath: /dev/shm
Expand All @@ -89,8 +85,8 @@ spec:
- name: logs
mountPath: /var/log/postgresql
- name: scripts
mountPath: /update-admin-password.sh
subPath: update-admin-password.sh
mountPath: /post-startup.sh
subPath: post-startup.sh
envFrom:
- secretRef:
name: {{ .Values.db.secretKeyRef.name }}
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ db:
log_directory: "/var/log/postgresql"
log_file_mode: 0644
log_filename: "postgresql-%d.log"
log_line_prefix: "'%m [%p] %q[user=%u,db=%d,app=%a]'"
log_line_prefix: "%m [%p] %q[user=%u,db=%d,app=%a] "
log_lock_waits: on

Check warning on line 126 in chart/values.yaml

View workflow job for this annotation

GitHub Actions / lint

126:21 [truthy] truthy value should be one of [false, true]
log_min_duration_statement: "1s"
log_rotation_age: "1d"
Expand Down

0 comments on commit 813b20a

Please sign in to comment.