Skip to content

feat(helm): allow init admin credentials from existing Kubernetes secret - #42753

Open
dominicl-proxora wants to merge 4 commits into
apache:masterfrom
dominicl-proxora:feature/chart-admin-credentials-secret
Open

feat(helm): allow init admin credentials from existing Kubernetes secret#42753
dominicl-proxora wants to merge 4 commits into
apache:masterfrom
dominicl-proxora:feature/chart-admin-credentials-secret

Conversation

@dominicl-proxora

Copy link
Copy Markdown

SUMMARY

This change adds support for sourcing Superset init admin credentials from an existing Kubernetes Secret.

Previously, admin credentials for init.createAdmin were expected from literal init.adminUser.* values (especially init.adminUser.password).
With this change, users can set init.adminUser.existingSecret and map key names via init.adminUser.secretKeys to provide:

  • username
  • firstname
  • lastname
  • email
  • password

Key implementation details:

  • init-job.yaml now injects admin env vars from secretKeyRef when existingSecret is set.
  • superset_init.sh generation in _helpers.tpl now uses env-based admin values when secret mode is enabled, otherwise keeps literal values behavior.
  • Security validation was updated: if init.createAdmin=true, either init.adminUser.password or init.adminUser.existingSecret must be set.
  • Helm docs and upgrading docs were updated (README.md, UPGRADING.md, values.yaml, values.schema.json).
  • Helm chart tests were extended to cover both literal and secret-based credential paths.

This enables setups where admin credentials are automatically provisioned (for example with randomly generated passwords) without storing them directly in values.yaml.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable (Helm chart/template behavior only).

TESTING INSTRUCTIONS

  1. Render chart with default/literal admin values and verify init script uses literal assignments:
    # values.yaml
    init:
      createAdmin: true
      adminUser:
        username: admin
        firstname: Superset
        lastname: Admin
        email: admin@superset.com
        password: adminpass
    • helm template ...
    • check generated superset_init.sh contains ADMIN_USERNAME="admin" (or configured value).
  2. Render chart with:
# values.yaml
init:
  createAdmin: true
  adminUser:
    existingSecret: superset-admin-credentials
    secretKeys:
      username: user
      firstname: firstname
      lastname: lastname
      email: email
      password: password

and verify render succeeds.

example for corresponding secret:

# Kubernetes Secret example
apiVersion: v1
kind: Secret
metadata:
  name: superset-admin-credentials
type: Opaque
stringData:
  user: admin
  firstname: Superset
  lastname: Admin
  email: admin@superset.com
  password: "<RANDOM_PASSWORD>"
  1. Verify generated init job contains env entries with secretKeyRef for:
    • SUPERSET_ADMIN_USERNAME
    • SUPERSET_ADMIN_FIRSTNAME
    • SUPERSET_ADMIN_LASTNAME
    • SUPERSET_ADMIN_EMAIL
    • SUPERSET_ADMIN_PASSWORD
  2. Run Helm chart tests and ensure they pass - helm unittest helm/superset
    • helm/superset/tests/config_test.yaml
    • helm/superset/tests/initscript_test.yaml
  3. (Optional runtime check) Deploy with an existing secret and confirm init job can create or detect admin user successfully.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review

bito-code-review Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #824edd

Actionable Suggestions - 0
Additional Suggestions - 1
  • helm/superset/tests/config_test.yaml - 1
    • Test lacks behavioral assertions · Line 74-83
      The test verifies the secret renders without crashing but doesn't assert the init script behavior — when `existingSecret` is set, the script must use `$SUPERSET_ADMIN_PASSWORD` env var instead of the literal empty password. Add regex assertions confirming environment variables are referenced, not literal values.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • helm/superset/templates/init-job.yaml - 1
    • CWE-249: Quoted secret name in secretKeyRef · Line 92-92
Review Details
  • Files reviewed - 5 · Commit Range: 34efc13..34efc13
    • helm/superset/templates/_helpers.tpl
    • helm/superset/templates/init-job.yaml
    • helm/superset/tests/config_test.yaml
    • helm/superset/tests/initscript_test.yaml
    • helm/superset/values.yaml
  • Files skipped - 3
    • helm/superset/README.md - Reason: Filter setting
    • helm/superset/UPGRADING.md - Reason: Filter setting
    • helm/superset/values.schema.json - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dominicl-proxora
dominicl-proxora force-pushed the feature/chart-admin-credentials-secret branch from 34efc13 to 2b24185 Compare August 4, 2026 08:53
@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 34efc13
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a71a81c1fdcdd000978c989
😎 Deploy Preview https://deploy-preview-42753--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread helm/superset/templates/_helpers.tpl Outdated
Comment on lines 213 to 215
{{- if and .Values.init.createAdmin (not (or $adminPasswordSet $adminSecretSet)) }}
{{- fail "SECURITY ERROR: init.createAdmin is true but neither init.adminUser.password nor init.adminUser.existingSecret is set. You must set a secure password using --set init.adminUser.password='your-password' or provide an existing Kubernetes secret via init.adminUser.existingSecret." }}
{{- end }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The validation runs whenever superset.config is included, including deployments and the config Secret, but it does not check init.enabled. Consequently, configurations that disable the init Job while leaving createAdmin enabled and clearing the unused password will fail Helm rendering even though no admin creation will run. Gate this validation on init.enabled as well. [api mismatch]

Severity Level: Major ⚠️
- ❌ Disabled init deployments fail Helm rendering unnecessarily.
- ⚠️ Config and deployment manifests cannot be generated.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** helm/superset/templates/_helpers.tpl
**Line:** 213:215
**Comment:**
	*Api Mismatch: The validation runs whenever `superset.config` is included, including deployments and the config Secret, but it does not check `init.enabled`. Consequently, configurations that disable the init Job while leaving `createAdmin` enabled and clearing the unused password will fail Helm rendering even though no admin creation will run. Gate this validation on `init.enabled` as well.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread helm/superset/templates/_helpers.tpl Outdated
Comment on lines +713 to +717
ADMIN_USERNAME={{ .Values.init.adminUser.username | quote }}
ADMIN_FIRSTNAME={{ .Values.init.adminUser.firstname | quote }}
ADMIN_LASTNAME={{ .Values.init.adminUser.lastname | quote }}
ADMIN_EMAIL={{ .Values.init.adminUser.email | quote }}
ADMIN_PASSWORD={{ .Values.init.adminUser.password | quote }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The literal values are rendered inside shell double quotes using Helm's quote, which is not shell escaping. Values containing $ or backticks can be expanded or command-substituted when the init script runs, and embedded shell-sensitive content can alter or break the assignments. Render these values with shell-safe single-quote escaping or pass them through environment variables instead. [security]

Severity Level: Critical 🚨
- ❌ Malicious credential values execute commands in init containers.
- ⚠️ Init pod service-account and mounted-secret access may be exposed.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** helm/superset/templates/_helpers.tpl
**Line:** 713:717
**Comment:**
	*Security: The literal values are rendered inside shell double quotes using Helm's `quote`, which is not shell escaping. Values containing `$` or backticks can be expanded or command-substituted when the init script runs, and embedded shell-sensitive content can alter or break the assignments. Render these values with shell-safe single-quote escaping or pass them through environment variables instead.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +719 to 728
if superset fab list-users 2>/dev/null | grep -qF 'username:'"${ADMIN_USERNAME}"; then
echo "Admin user already exists, skipping."
else
superset fab create-admin \
--username {{ .Values.init.adminUser.username | squote }} \
--firstname {{ .Values.init.adminUser.firstname | squote }} \
--lastname {{ .Values.init.adminUser.lastname | squote }} \
--email {{ .Values.init.adminUser.email | squote }} \
--password {{ .Values.init.adminUser.password | squote }}
--username "${ADMIN_USERNAME}" \
--firstname "${ADMIN_FIRSTNAME}" \
--lastname "${ADMIN_LASTNAME}" \
--email "${ADMIN_EMAIL}" \
--password "${ADMIN_PASSWORD}"
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: With /bin/sh, the pipeline status is the status of grep, not superset fab list-users. A database or CLI failure from list-users is therefore treated as a non-match and the script proceeds to create-admin, while the original error is suppressed by 2>/dev/null. This can produce a misleading creation error or create an account despite an unavailable metadata database. Preserve and fail on the list-users error before attempting creation. [possible bug]

Severity Level: Major ⚠️
- ⚠️ Database/listing failures are misreported during initialization.
- ❌ Init Jobs may attempt account creation after failed discovery.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** helm/superset/templates/_helpers.tpl
**Line:** 719:728
**Comment:**
	*Possible Bug: With `/bin/sh`, the pipeline status is the status of `grep`, not `superset fab list-users`. A database or CLI failure from `list-users` is therefore treated as a non-match and the script proceeds to `create-admin`, while the original error is suppressed by `2>/dev/null`. This can produce a misleading creation error or create an account despite an unavailable metadata database. Preserve and fail on the `list-users` error before attempting creation.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list-users | grep existed before

@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 656eebb
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a71b7a3522fe20008dcd1af
😎 Deploy Preview https://deploy-preview-42753--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@dominicl-proxora
dominicl-proxora force-pushed the feature/chart-admin-credentials-secret branch from 1f99a74 to 656eebb Compare August 4, 2026 09:57
@bito-code-review

bito-code-review Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #bc27b3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 6 · Commit Range: 55fc954..3233a5f
    • helm/superset/Chart.yaml
    • helm/superset/templates/_helpers.tpl
    • helm/superset/templates/init-job.yaml
    • helm/superset/tests/config_test.yaml
    • helm/superset/tests/initscript_test.yaml
    • helm/superset/values.yaml
  • Files skipped - 2
    • helm/superset/README.md - Reason: Filter setting
    • helm/superset/values.schema.json - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread helm/superset/values.yaml
# instead of from the values above. The secret keys are configurable via `secretKeys`.
existingSecret: ""
# -- Keys inside the existing secret that hold admin user fields.
secretKeys:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the existingSecret above can be nested into secretKeys for better org. existingSecret sounds generic enough to conflict with other future possible changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs to fix the failed pre-commit CI by running helm docs on the helm/superset dir

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

Labels

deploy:helm install:config Installation - Configuration settings size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants