diff --git a/chart/templates/backend-migration.job.yaml b/chart/templates/backend-migration.job.yaml index dd26377..5a1cde8 100644 --- a/chart/templates/backend-migration.job.yaml +++ b/chart/templates/backend-migration.job.yaml @@ -14,7 +14,15 @@ spec: - name: wait-for-postgres image: postgres:15 command: ['sh', '-c', - 'until pg_isready -h postgres-service -p 5432 -U prod_admin; do echo waiting for postgres; sleep 2; done;'] + 'echo "Waiting for PostgreSQL to be ready..." && \ + for i in $(seq 1 30); do \ + if pg_isready -h postgres-service -p 5432 -U prod_admin; then \ + echo "PostgreSQL is ready!" && exit 0; \ + fi; \ + echo "Attempt $i: PostgreSQL is not ready yet. Waiting..." && \ + sleep 10; \ + done; \ + echo "PostgreSQL failed to become ready in time" && exit 1;'] env: - name: PGPASSWORD value: "{{ .Values.backend.env.POSTGRES_PASSWORD }}" diff --git a/chart/templates/postgres-configmap.yaml b/chart/templates/postgres-configmap.yaml index da07a72..608ec67 100644 --- a/chart/templates/postgres-configmap.yaml +++ b/chart/templates/postgres-configmap.yaml @@ -8,7 +8,7 @@ data: local all all trust host all all 127.0.0.1/32 trust host all all ::1/128 trust - host all all 0.0.0.0/0 md5 + host all all 0.0.0.0/0 scram-sha-256 postgresql.conf: | # Connection Settings listen_addresses = '*' @@ -48,4 +48,11 @@ data: # Other Settings dynamic_shared_memory_type = posix effective_io_concurrency = 200 - default_statistics_target = 100 \ No newline at end of file + default_statistics_target = 100 + + # Authentication + password_encryption = scram-sha-256 + + # Error Reporting + log_min_error_statement = error + log_statement = 'all' \ No newline at end of file diff --git a/chart/templates/postgres-deployment.yaml b/chart/templates/postgres-deployment.yaml index 9769b68..bd7d3a2 100644 --- a/chart/templates/postgres-deployment.yaml +++ b/chart/templates/postgres-deployment.yaml @@ -24,6 +24,37 @@ spec: value: "{{ .Values.postgres.user }}" - name: POSTGRES_PASSWORD value: "{{ .Values.postgres.password }}" + - name: POSTGRES_HOST_AUTH_METHOD + value: "scram-sha-256" + startupProbe: + exec: + command: + - pg_isready + - -U + - "{{ .Values.postgres.user }}" + initialDelaySeconds: 10 + periodSeconds: 5 + failureThreshold: 30 + readinessProbe: + exec: + command: + - pg_isready + - -U + - "{{ .Values.postgres.user }}" + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 5 + livenessProbe: + exec: + command: + - pg_isready + - -U + - "{{ .Values.postgres.user }}" + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 volumeMounts: - mountPath: /var/lib/postgresql/data name: postgres-data