mirror of
https://gitlab.kube.huskypup.net/Scooby/Homelabv4.git
synced 2026-08-21 05:26:49 +00:00
Fix real cause of VPS authentik's DB timeout loop + repo secrets cleanup
Root cause of the 'PostgreSQL connection failed, retrying... (connection timeout expired)' loop that survived every earlier fix (streaming replication, the password sync, the port fix, the CoreDNS override): authentik's Helm values had TWO sources for AUTHENTIK_POSTGRESQL__HOST/ PORT - an explicit uppercase env: override (pointed at the floating pg-authentik.ha.huskypup.net:61432) AND a chart-generated envFrom secretRef (pg-authentik-app, prefix: AUTHENTIK_POSTGRESQL__) whose keys are lowercase (host, port, ...), producing a SEPARATE AUTHENTIK_POSTGRESQL__host/port pair pointing at the old local pg-authentik-rw:5432. Kubernetes treats these as two unrelated env vars (case-sensitive), but authentik's own generic AUTHENTIK_*-prefixed env-var scanner apparently doesn't, and was resolving to the lowercase (stale, local) values regardless of the explicit override - confirmed live by dumping the pod's actual env: both HOST and host were present with different values. Removed the now-fully-redundant envFrom entry (every key it provided is already explicitly set via valueFrom). Also: user correctly pointed out plaintext secrets don't belong in the repo. Audited for the same class of issue as the already-fixed Cloudflare token (infrastructure/cert-manager/manifests/secret-cf-token.yaml): - infrastructure/external-dns/manifests/secret-external-dns-unifi.yaml had a live UniFi API key in plaintext - moved to Vault+ExternalSecret, same pattern as the Cloudflare token fix. The key itself is still the original (now Vault-stored) value - rotating it requires the UniFi web UI (no self-service API), noted in the file as a separate pending step. - infrastructure/vps-eso/manifests/clustersecretstore.yaml had the AppRole's roleId inline (added this session) - moved to roleRef, sourced from the same Secret as secretId, consistent with 'nothing sensitive in git' regardless of how sensitive one field is alone. NOT touched, flagged separately for the user: infrastructure/authentik/ *-blueprint.yaml (vault, gitlab, n8n, nextcloud, rancher, grafana, argocd, guacamole) all have live-looking high-entropy client_secret values hardcoded in plaintext - same class of issue but much larger blast radius (8 apps' SSO), needs its own coordinated rotation, not bundled into this commit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
cfbe844ecd
commit
185e9c292e
@@ -13,10 +13,23 @@ global:
|
||||
# First secret: Authentik-specific settings (AUTHENTIK_SECRET_KEY)
|
||||
- secretRef:
|
||||
name: authentik
|
||||
# Second secret: Database credentials from CNPG
|
||||
- secretRef:
|
||||
name: pg-authentik-app
|
||||
prefix: AUTHENTIK_POSTGRESQL__
|
||||
# The second secretRef (pg-authentik-app, prefix: AUTHENTIK_POSTGRESQL__)
|
||||
# that used to live here is GONE - found live 2026-08-20 that it was
|
||||
# actively breaking things, not just redundant. That prefix mechanism
|
||||
# copies the raw secret's lowercase keys (host, port, dbname, username,
|
||||
# password) into lowercase-suffixed env vars (AUTHENTIK_POSTGRESQL__host,
|
||||
# etc.) - env var names are case-sensitive to Kubernetes, but authentik's
|
||||
# own generic AUTHENTIK_*-prefixed env-var scanner is NOT, and it was
|
||||
# picking up the lowercase AUTHENTIK_POSTGRESQL__host=pg-authentik-rw
|
||||
# instead of the explicit uppercase AUTHENTIK_POSTGRESQL__HOST override
|
||||
# below - silently connecting to the local CNPG service on port 5432
|
||||
# the whole time regardless of what HOST/PORT were explicitly set to,
|
||||
# surfacing as an unexplained "connection timeout expired" loop (the
|
||||
# local hostname resolves fine in-cluster but on the VPS the request
|
||||
# apparently doesn't complete - never fully root-caused, just confirmed
|
||||
# dropping this duplicate source fixes it). Every key that secretRef
|
||||
# used to provide (dbname/username/password) is already explicitly set
|
||||
# via valueFrom below, so nothing is lost by removing it.
|
||||
env:
|
||||
# Configure external URL for proper OIDC discovery responses
|
||||
- name: AUTHENTIK_URL
|
||||
|
||||
Reference in New Issue
Block a user