feat(chart): add support for variables from existing secrets#134
Open
kamiKAC wants to merge 2 commits into
Open
feat(chart): add support for variables from existing secrets#134kamiKAC wants to merge 2 commits into
kamiKAC wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="charts/n8n/values.schema.json">
<violation number="1" location="charts/n8n/values.schema.json:525">
P1: Schema `anyOf` branches for database.existingSecret and database.userSecret lack `required`, causing them to pass vacuously when the property is absent. This allows invalid database configurations to incorrectly pass validation.</violation>
</file>
Architecture diagram
sequenceDiagram
participant User as Helm User
participant CLI as Helm CLI
participant Chart as n8n Chart (values.yaml + helpers)
participant Schema as values.schema.json
participant ConfigMap as ConfigMap (configmap.yaml)
participant Secret as Kubernetes Secret (existing)
participant Pod as n8n Pod (worker/main)
Note over User,Pod: Helm Chart Deployment Flow
User->>CLI: helm install/upgrade with values
CLI->>Chart: Load values.yaml + user overrides
Note over Chart,Schema: Chart Validation Phase
Chart->>Schema: Validate against schema.json
Schema-->>Chart: Validation result
alt queueMode.enabled = true
Schema->>Chart: Check database requirements
alt database.host/port/database provided
Note over Chart,Schema: Direct values path (no change)
else database.existingSecret.name is set
Note over Chart,Schema: Secret-backed path (NEW)
end
alt database.user provided
Note over Chart,Schema: Direct value path
else database.userSecret.name is set
Note over Chart,Schema: User from secret (NEW)
end
alt redis.host or redis.clusterNodes provided
Note over Chart,Schema: Direct values path
else redis.existingSecret name + hostKey/clusterNodesKey
Note over Chart,Schema: Redis config from secret (NEW)
end
alt redis.username provided
Note over Chart,Schema: Direct username
else redis.usernameSecret.name is set
Note over Chart,Schema: Username from secret (NEW)
end
end
Chart->>ConfigMap: Generate configmap.yaml
Note over ConfigMap: Conditionally omit keys<br/>when secret-backed
alt database.existingSecret.name + databaseKey
Note over ConfigMap: Skip DB_POSTGRESDB_DATABASE in ConfigMap
else
ConfigMap->>ConfigMap: Include DB_POSTGRESDB_DATABASE
end
alt database.existingSecret.name + hostKey
Note over ConfigMap: Skip DB_POSTGRESDB_HOST in ConfigMap
end
alt database.existingSecret.name + portKey
Note over ConfigMap: Skip DB_POSTGRESDB_PORT in ConfigMap
end
alt database.userSecret.name
Note over ConfigMap: Skip DB_POSTGRESDB_USER in ConfigMap
end
alt redis.existingSecret.name + clusterNodesKey
Note over ConfigMap: Skip REDIS_CLUSTER_NODES in ConfigMap
else redis.existingSecret.name + hostKey
Note over ConfigMap: Skip REDIS_HOST in ConfigMap
end
alt redis.existingSecret.name + portKey
Note over ConfigMap: Skip REDIS_PORT in ConfigMap
end
alt redis.usernameSecret.name
Note over ConfigMap: Skip REDIS_USERNAME in ConfigMap
end
ConfigMap-->>Pod: Mount as environment
Note over Pod: Env vars from ConfigMap
Pod->>Secret: Read secret-backed values (NEW)
Note over Pod: DB/Redis connection values<br/>sourced from existing Secrets
Pod->>Pod: n8n starts with resolved config
Note over Pod: DB_POSTGRESDB_HOST/PORT/DATABASE/USER<br/>QUEUE_BULL_REDIS_HOST/PORT/CLUSTER_NODES/USERNAME
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| "port": { "type": "integer" }, | ||
| "database": { "type": "string" }, | ||
| "user": { "type": "string" }, | ||
| "existingSecret": { |
Contributor
There was a problem hiding this comment.
P1: Schema anyOf branches for database.existingSecret and database.userSecret lack required, causing them to pass vacuously when the property is absent. This allows invalid database configurations to incorrectly pass validation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At charts/n8n/values.schema.json, line 525:
<comment>Schema `anyOf` branches for database.existingSecret and database.userSecret lack `required`, causing them to pass vacuously when the property is absent. This allows invalid database configurations to incorrectly pass validation.</comment>
<file context>
@@ -522,6 +522,24 @@
"port": { "type": "integer" },
"database": { "type": "string" },
"user": { "type": "string" },
+ "existingSecret": {
+ "type": "object",
+ "properties": {
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds support for sourcing selected database and Redis connection values from existing Kubernetes Secrets.
This change avoids duplicate environment variable definitions in queue mode by rendering each DB and Redis env var from either a ConfigMap or a Secret, depending on the configured secret keys. It also updates chart validation so the required values can be provided either directly or through secret references.
Type of Change
Related Issues
Fixes # (issue)
Relates to # (issue)
Changes Made
database.host,database.port, anddatabase.databasefromdatabase.existingSecret.database.userfromdatabase.userSecret.redis.host,redis.port, andredis.clusterNodesfromredis.existingSecret.redis.usernamefromredis.usernameSecret._configmap-env.tplandconfigmap.yamlso DB and Redis variables are defined only once, preventing duplicate env entries in the worker deployment._helpers.tplvalidation to allow either direct values or secret-backed configuration for queue mode requirements.values.schema.jsonwith the new secret objects and direct-or-secret validation rules.values.yaml.Testing Performed
Chart Validation
helm lint charts/n8npasses./scripts/validate-examples.shpassesDeployment Testing (if applicable)
Specific Testing for Changes
Describe any specific testing you performed for your changes:
helm lint charts/n8nsuccessfully.helm templateagainst all example values files with a non-placeholder encryption key and verified they all render successfully:keda-autoscaling.yamlminimal-with-docker.yamlminimal.yamlmulti-main-queue.yamlproduction-s3.yamlstandalone.yamltask-runners.yamlDB_POSTGRESDB_USER,DB_POSTGRESDB_PORT,DB_POSTGRESDB_HOST,DB_POSTGRESDB_DATABASE,QUEUE_BULL_REDIS_HOST, andQUEUE_BULL_REDIS_PORT.Breaking Changes
If this includes breaking changes, describe what they are and provide migration instructions:
Documentation Updates
Checklist
Screenshots (if applicable)
Add screenshots to help explain your changes.
Additional Notes