Skip to content

feat: load raft.token from external-secrets - #30

Open
siryur wants to merge 2 commits into
pgdogdev:mainfrom
siryur:feat/raft-token-external-secrets
Open

siryur wants to merge 2 commits into
pgdogdev:mainfrom
siryur:feat/raft-token-external-secrets

Conversation

@siryur

@siryur siryur commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

raft.token can only be set inline or generated by the chart, so the token can't come from an external secret store.

Adds raft.externalSecrets, mirroring the control.externalSecrets block in #19: the chart renders an ExternalSecret, reads the token key off its target Secret, and stops creating its own -raft Secret so the two don't fight over ownership. The printable-ASCII check moves to the resolved token, catching the trailing newline secret stores usually add.

The token is resolved by lookup, so a plain helm template (or an install before the operator has synced) still falls back to a generated token; the next helm upgrade picks up the real one. Documented in the README.

Verified: ./test/test.sh and control2 configcheck pass on the new test/values-raft-external-secrets.yaml.

Fix #29

The shared Raft peer token had two sources: an inline raft.token, or a
token the chart generates and reuses via a lookup against the
<release>-raft Secret. Neither let users keep the token in an external
secret store and hand it to the cluster through the external-secrets
operator, which is how the rest of their secrets already arrive.

Add raft.externalSecrets, mirroring the block proposed for cookie_secret
in pgdogdev#19, plus a templates/raft-externalsecret.yaml that renders an
ExternalSecret when enabled. Its target Secret name is shared with the
chart's existing lookup-based token resolution, so a synced token key
flows into control.toml exactly like the generated one does, and the
chart stops rendering its own <release>-raft Secret to avoid fighting
the ExternalSecret for ownership.

Move the printable-ASCII check to the resolved token, so a value read
from a Secret is rejected for the trailing newline secret stores
commonly carry rather than silently breaking peer authentication.

Fix pgdogdev#29
@levkk

levkk commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Hmm, I would rather store it as a Secret instead. Pretty sure that's what we do for other secrets like this, e.g., datadog api key in the pgdog helm chart.

@siryur

siryur commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

An external-secret just ends-up creating a k8s secret anyway. So, in terms of the final result, it should be pretty much the same, but this allows to configure the secret value somewhere else rather than just use helm - which can be helpful in many scenarios/setups

In my case, I want to commit the resulting helm manifests to git (with helm template ...) - so this will mean that the secret value will be commited in git. With the external-secret, I manage it somewhere else and I just reference the source of it.

@levkk

levkk commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Yeah makes sense. We need to add support for configuring control.toml via environment variables - basically all settings should be accepted from the env. Then, we can mount external secrets into the container (wherever they come from).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for loading raft.token from external-secrets

2 participants