Skip to content

fix(k0s): generate kubeflex postgres password at first boot instead of hardcoding it - #102

Merged
castrojo merged 1 commit into
projectbluefin:mainfrom
kylerankin:fix/kubeflex-postgres-secret
Sep 13, 2026
Merged

fix(k0s): generate kubeflex postgres password at first boot instead of hardcoding it#102
castrojo merged 1 commit into
projectbluefin:mainfrom
kylerankin:fix/kubeflex-postgres-secret

Conversation

@kylerankin

Copy link
Copy Markdown
Contributor

Fixes #98

The postgres StatefulSet seeded into every default Bluefin Server install
hardcoded the PostgreSQL superuser password as a plaintext env var
(value: "kubeflex", the publicly documented kubeflex default) in
files/k0s/manifests/kubestellar/20-postgres.yaml. That manifest is
auto-applied by the k0s manifest deployer on every install, so the credential
was committed to git in plaintext and readable from any pod spec in
kubeflex-system.

Changes:

  • Read the password from a Kubernetes Secret (kubeflex-postgres) via
    valueFrom.secretKeyRef instead of a plaintext env value.
  • Generate that Secret once at first boot with a random password.
    files/k0s/kubeflex/generate-postgres-secret.sh runs from
    k0s-first-boot.service after the manifests dir is seeded and before k0s
    applies manifests (its 15- name sorts before 20-postgres.yaml, so the
    Secret exists first). The generator is idempotent, so the initialized
    database stays accessible across re-boots. Nothing sensitive is committed to
    git.
  • Stage the helper in the k0s sysext (elements/oci/k0s-sysext.bst).
  • Cover the new behavior in tests/unit/test_k0s_manifests.py.

This follows the same remediation shape recommended for #72 (move credentials
into a Secret referenced via secretKeyRef) and keeps the default install
working out of the box. Existing clusters should still rotate the postgres
password per recommendation #3 in the issue.

— hive: backend=pi model=lemonade/Ornith-1.5-35B-A3B-GGUF-Q6_K

🐝 Hive Agent: contributor | SHA: dbf5d8e

…f hardcoding it

The postgres StatefulSet seeded into every default Bluefin Server install
hardcoded the superuser password as a plaintext env var (value: "kubeflex",
the publicly documented kubeflex default) in 20-postgres.yaml. That manifest
is auto-applied by the k0s deployer on every install, so the credential was
committed to git in plaintext and readable from any pod spec in
kubeflex-system.

- Read the password from the kubeflex-postgres Secret via secretKeyRef.
- Generate that Secret once at first boot with a random password
  (generate-postgres-secret.sh, run by k0s-first-boot.service before k0s
  applies manifests; its 15- name sorts before 20-postgres.yaml). The
  generator is idempotent so the initialized database stays accessible
  across re-boots. Nothing sensitive is committed to git.
- Stage the helper in the k0s sysext and cover the new behavior in tests.

Signed-off-by: kylerankin <kylerankin@users.noreply.github.com>
@castrojo
castrojo merged commit b50b791 into projectbluefin:main Sep 13, 2026
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.

[sec-check] kubestellar postgres StatefulSet hardcodes superuser password 'kubeflex' as plaintext env, auto-applied by default

2 participants