Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Add environment settings to worker deployment #143

Conversation

dominykasn
Copy link
Contributor

@dominykasn dominykasn commented Feb 19, 2025

Would be nice to be able to set N8N_ENCRYPTION_KEY and other settings in worker as right now it is not possible and not possible to run workers at all, this could fix the issue

Summary by CodeRabbit

  • New Features

    • Enhanced worker deployment flexibility with new options for custom configuration, environment variables, and secret management.
  • Chores

    • Upgraded the Helm chart to version 1.1.0 with refined descriptive annotations for improved clarity.

@dominykasn dominykasn requested a review from a team as a code owner February 19, 2025 11:12
Copy link

coderabbitai bot commented Feb 19, 2025

Walkthrough

This PR updates the n8n Helm chart by bumping its version and modifying the annotation description in the Chart.yaml to emphasize environment settings for the worker deployment. It adds new template files for conditionally creating a ConfigMap and a Secret for the worker, adjusts the worker deployment template to source environment variables and secrets conditionally, and extends the values file with new options for worker configuration.

Changes

File(s) Change Summary
charts/n8n/Chart.yaml Updated version from 1.0.1 to 1.1.0 and modified annotation description to "Add environment settings to worker deployment."
charts/n8n/templates/configmap.worker.yaml
charts/n8n/templates/secret.worker.yaml
Added new conditional templates for creating a ConfigMap and a Secret based on worker.config and worker.secret values respectively.
charts/n8n/templates/deployment.worker.yaml Introduced an envFrom section to conditionally source configuration maps and secrets, and added handling for extra environment variables.
charts/n8n/values.yaml Added new entries (config, secret, extraEnv) under the worker section to enable further configuration of the worker component.

Sequence Diagram(s)

sequenceDiagram
    participant Helm as "Helm CLI"
    participant Template as "Helm Template Engine"
    participant K8s as "Kubernetes API Server"
    participant Worker as "Worker Container"
    
    Helm->>Template: Load values.yaml and Chart templates
    alt worker.config is defined
        Template->>K8s: Render and deploy ConfigMap for worker
    end
    alt worker.secret is defined
        Template->>K8s: Render and deploy Secret for worker
    end
    Template->>K8s: Render Deployment with envFrom and extraEnv settings
    K8s->>Worker: Start Worker container with configured environment variables
Loading

Possibly related PRs

  • feat: Release 1.0.1 #142: Updates related to the Helm chart version and annotation modifications that preceded these changes.
  • Next Gen Chart #132: Adjustments in worker deployment configurations including environment variable handling in the Helm chart templates.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
charts/n8n/templates/configmap.worker.yaml (1)

1-11: Helm Templating & YAMLlint Note:
The conditional block for generating the ConfigMap based on .Values.worker.config is correctly structured using Helm templating. The YAMLlint error on line 1 (regarding the expected node content before the dash) is a known false positive when linting templates. Consider adding a YAMLlint ignore comment (or configuring your linter) for Helm template files so that such false errors are suppressed.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/secret.worker.yaml (1)

1-13: Helm Templating & Secret Resource Creation:
This new file correctly defines a Secret that is conditionally created when .Values.worker.secret is provided. Similar to the ConfigMap file, the templating syntax may trigger YAML lint warnings at the very start; these can be safely ignored or suppressed via linter configuration. The use of the toEnvVars function with the "isSecret": true flag is appropriate for handling sensitive data.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/deployment.worker.yaml (1)

72-76: Handling Additional Environment Variables (extraEnv):
The addition of the env block to process .Values.worker.extraEnv is a useful feature. However, the use of the expression

env: {{ not (empty .Values.worker.extraEnv) | ternary nil "[]" }}

may be slightly nonintuitive. In this context, if extraEnv is not empty, the block outputs nil (thus allowing the subsequent range to append the proper entries), and if it is empty, outputs an empty list. It might help future maintainers if an inline comment explains this logic. Please verify that this behavior is as intended.

charts/n8n/values.yaml (1)

263-274: New Worker Configuration Options:
The addition of the config, secret, and extraEnv keys within the worker section is well structured and clearly laid out. These new entries allow users to specify additional environment variables and sensitive settings for the worker component. Please ensure that the accompanying documentation (e.g., README or values documentation) is updated to describe these new options.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce65c6b and d1838a3.

📒 Files selected for processing (5)
  • charts/n8n/Chart.yaml (2 hunks)
  • charts/n8n/templates/configmap.worker.yaml (1 hunks)
  • charts/n8n/templates/deployment.worker.yaml (1 hunks)
  • charts/n8n/templates/secret.worker.yaml (1 hunks)
  • charts/n8n/values.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
charts/n8n/templates/secret.worker.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/configmap.worker.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint-test
🔇 Additional comments (3)
charts/n8n/Chart.yaml (2)

3-3: Helm Chart Version Update:
The Helm chart version has been updated to 1.1.0, which aligns with the new features introduced in this PR. Ensure that all related documentation (e.g., CHANGELOG or release notes) is updated accordingly.


36-38: Annotation Update for Worker Deployment:
The annotation description is updated to "Add environment settings to worker deployment". This revision clearly communicates the focus of the PR. Double-check that this updated description is also reflected in any external documentation or automated release checks.

charts/n8n/templates/deployment.worker.yaml (1)

55-63: Conditional Inclusion of Environment Sources:
The newly introduced envFrom block conditionally includes references for both main and worker configuration (via configMapRef and secretRef). This enhances the flexibility of the worker deployment by allowing it to source environment variables from multiple resources. The conditionals for .Values.main.config, .Values.main.secret, .Values.worker.config, and .Values.worker.secret are clear and seem appropriately placed.

@Vad1mo
Copy link
Member

Vad1mo commented Feb 20, 2025

thank you, as you guessed, the worker, webhook aren't yet fully tested or implemented.
My plan is to do some tests in the near future.

@Vad1mo Vad1mo merged commit 8d3932f into 8gears:main Feb 20, 2025
3 checks passed
@dominykasn
Copy link
Contributor Author

dominykasn commented Feb 20, 2025

No problem, can we release this? If so, how should it be done? I think contribution bullet point lacks some information

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants