fix(pangolin): Render postgres.connection_string into config.yml at startup

Pangolin's PostgreSQL build requires postgres.connection_string in
config.yml — DATABASE_URL alone is not honored as an override, so the
container was crashing with "Postgres configuration is missing in the
configuration file".

Render the final config.yml at pod startup via a busybox init container
that substitutes the DATABASE_URL secret into a __DATABASE_URL__
placeholder in the ConfigMap template, then mount the rendered file
into the pangolin container.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
CTO Agent 2026-08-08 11:17:40 +00:00
parent 3fff00cfd0
commit ca23917797
2 changed files with 34 additions and 4 deletions

View file

@ -1,12 +1,15 @@
--- ---
# Pangolin ConfigMap # Pangolin ConfigMap
# The `postgres.connection_string` placeholder is replaced at pod startup
# by the render-config init container using DATABASE_URL from the sealed
# secret. See pangolin-deployment.yaml.
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: pangolin-config name: pangolin-config
namespace: pangolin namespace: pangolin
data: data:
config.yml: | config.yml.tmpl: |
gerbil: gerbil:
start_port: 10000 start_port: 10000
base_endpoint: "pangolin.basicstack.de" base_endpoint: "pangolin.basicstack.de"
@ -29,6 +32,9 @@ data:
signup: true signup: true
verification: false verification: false
postgres:
connection_string: "__DATABASE_URL__"
oidc: oidc:
enabled: true enabled: true
issuer: "https://auth.basicstack.de" issuer: "https://auth.basicstack.de"

View file

@ -57,6 +57,29 @@ spec:
secretKeyRef: secretKeyRef:
name: pangolin-postgres-secrets name: pangolin-postgres-secrets
key: postgres-db key: postgres-db
- name: render-config
image: busybox:1.37
command:
- /bin/sh
- -c
- |
set -e
# Escape sed replacement metacharacters in the connection string
esc=$(printf '%s' "$DATABASE_URL" | sed -e 's/[\/&|]/\\&/g')
sed "s|__DATABASE_URL__|$esc|" /tmpl/config.yml.tmpl > /rendered/config.yml
echo "rendered config.yml (secrets redacted):"
sed 's|connection_string:.*|connection_string: <redacted>|' /rendered/config.yml
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: pangolin-postgres-secrets
key: connection-string
volumeMounts:
- name: config-tmpl
mountPath: /tmpl
- name: config-rendered
mountPath: /rendered
containers: containers:
- name: pangolin - name: pangolin
image: fosrl/pangolin:postgresql-1.21.1 image: fosrl/pangolin:postgresql-1.21.1
@ -68,7 +91,6 @@ spec:
env: env:
- name: PANGOLIN_URL - name: PANGOLIN_URL
value: "https://pangolin.basicstack.de" value: "https://pangolin.basicstack.de"
# PostgreSQL database URL (Pangolin PostgreSQL variant reads this at startup)
- name: DATABASE_URL - name: DATABASE_URL
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
@ -102,7 +124,7 @@ spec:
volumeMounts: volumeMounts:
- name: pangolin-data - name: pangolin-data
mountPath: /app/config mountPath: /app/config
- name: config - name: config-rendered
mountPath: /app/config/config.yml mountPath: /app/config/config.yml
subPath: config.yml subPath: config.yml
resources: resources:
@ -132,9 +154,11 @@ spec:
- name: pangolin-data - name: pangolin-data
persistentVolumeClaim: persistentVolumeClaim:
claimName: pangolin-data claimName: pangolin-data
- name: config - name: config-tmpl
configMap: configMap:
name: pangolin-config name: pangolin-config
- name: config-rendered
emptyDir: {}
--- ---
# Pangolin Service # Pangolin Service
apiVersion: v1 apiVersion: v1