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:
parent
3fff00cfd0
commit
ca23917797
2 changed files with 34 additions and 4 deletions
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
# 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
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: pangolin-config
|
||||
namespace: pangolin
|
||||
data:
|
||||
config.yml: |
|
||||
config.yml.tmpl: |
|
||||
gerbil:
|
||||
start_port: 10000
|
||||
base_endpoint: "pangolin.basicstack.de"
|
||||
|
|
@ -29,6 +32,9 @@ data:
|
|||
signup: true
|
||||
verification: false
|
||||
|
||||
postgres:
|
||||
connection_string: "__DATABASE_URL__"
|
||||
|
||||
oidc:
|
||||
enabled: true
|
||||
issuer: "https://auth.basicstack.de"
|
||||
|
|
|
|||
|
|
@ -57,6 +57,29 @@ spec:
|
|||
secretKeyRef:
|
||||
name: pangolin-postgres-secrets
|
||||
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:
|
||||
- name: pangolin
|
||||
image: fosrl/pangolin:postgresql-1.21.1
|
||||
|
|
@ -68,7 +91,6 @@ spec:
|
|||
env:
|
||||
- name: PANGOLIN_URL
|
||||
value: "https://pangolin.basicstack.de"
|
||||
# PostgreSQL database URL (Pangolin PostgreSQL variant reads this at startup)
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
@ -102,7 +124,7 @@ spec:
|
|||
volumeMounts:
|
||||
- name: pangolin-data
|
||||
mountPath: /app/config
|
||||
- name: config
|
||||
- name: config-rendered
|
||||
mountPath: /app/config/config.yml
|
||||
subPath: config.yml
|
||||
resources:
|
||||
|
|
@ -132,9 +154,11 @@ spec:
|
|||
- name: pangolin-data
|
||||
persistentVolumeClaim:
|
||||
claimName: pangolin-data
|
||||
- name: config
|
||||
- name: config-tmpl
|
||||
configMap:
|
||||
name: pangolin-config
|
||||
- name: config-rendered
|
||||
emptyDir: {}
|
||||
---
|
||||
# Pangolin Service
|
||||
apiVersion: v1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue