Fix NATS auth: wrap env-var passwords in << >> so the server expands them #306
Reference in New Issue
Block a user
Delete Branch "benvin/logging-deploy-fixes-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
After #301 merged, the stack was still broken. Live diagnosis found the actual NATS auth root cause (my earlier interpolation fix in #301 was necessary but not sufficient).
Evidence
authorization violation: thenats-bootstrapPostSync Job hung 30 min aslog-adminthen failedDeadlineExceeded(itsuntil nats account infoloop never authenticated), andvector-aggregator/vector-archivercrash-looped.log-adminwith the literal string$NATS_ADMIN_PASSWORDsucceeded — proving the server stored the passwords un-expanded.Root cause
The nats chart renders
config.mergeas JSON, so a plainpassword: $NATS_ADMIN_PASSWORDbecomes the quoted literal"$NATS_ADMIN_PASSWORD"innats.conf, and NATS does not expand variables inside quoted strings. Per the chart README, env vars must be wrapped in<< $VAR >>to render unquoted so NATS expands them.What
Wrap all three user passwords in
<< >>:Rendered
nats.confnow emits"password": $NATS_ADMIN_PASSWORD(unquoted).This is the server-side half; #301 (merged) fixed the client-side half (Vector 0.57 needs
VECTOR_DANGEROUSLY_ALLOW_ENV_VAR_INTERPOLATIONto send the real password). Both are required — with both, server-expanded password == vector-interpolated password.Verified end-to-end
nats-server with unquoted
$VARconfig + env, plus vector with the interpolation flag: adminaccount infoOK,LOGSstream +transformconsumer created, and the vector consumer connects successfully.Expected recovery after merge + sync
nats-configCM updates → the config-reloader reloads NATS with the real (expanded) passwords.logging-loggingsync retries; the Sync phase applies #301's vector env + this config.nats-bootstrapPostSync hook now authenticates as admin → creates theLOGSstream +transform/archiverconsumers → sync completes.nats stream info LOGSshows messages;SELECT count() FROM logs.rawrises.ClickHouse itself is already healthy (chi-logs Running, schema Job Complete) thanks to #301's watchNamespaces fix.
Validation
kustomize + kubeconform clean (logging 40); rendered
nats.confshows unquoted$VAR; pre-commit clean.https://claude.ai/code/session_015ur3i7D2azsMAWTSVABApv