Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add support for custom deployment annotations and labels #144

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dadangnh
Copy link

@dadangnh dadangnh commented Feb 21, 2025

Add support for custom deployment annotations and labels

Description

This PR is a follow up of the previously raised PR, it adds support for custom annotations and labels at the deployment level. Previously, the chart only supported pod-level annotations and labels. This enhancement allows users to add Kubernetes annotations and labels specifically at the deployment level, which is useful for various deployment management and integration scenarios.

Changes Made

  • Added new deploymentAnnotations and deploymentLabels fields on each component (main. worker, webhook) in values.yaml
  • Updated all deployment manifests (main, webhook, and worker) to support the new fields
  • Maintained backwards compatibility by making the new fields optional
  • Kept existing pod-level annotations and labels functionality unchanged

Example Usage

# values.yaml or values override
main:
  deploymentAnnotations:
    fluxcd.io/automated: "true"
    notification.monitor.io/slack: "true"
  
  deploymentLabels:
    environment: production
    team: platform
    component: n8n

worker:
  deploymentAnnotations:
    fluxcd.io/automated: "true"
    notification.monitor.io/slack: "true"
  
  deploymentLabels:
    environment: production
    team: platform
    component: n8n-worker

webhook:
  deploymentAnnotations:
    fluxcd.io/automated: "true"
    notification.monitor.io/slack: "true"
  
  deploymentLabels:
    environment: production
    team: platform
    component: n8n-webhook

Summary by CodeRabbit

  • New Features
    • Added options for custom annotations and labels across deployments and pods, enhancing flexibility for managing metadata in your Kubernetes environment.
  • Chores
    • Updated the system version from 1.1.0 to 1.2.0 and refreshed descriptive text to reflect the new configuration capabilities.

@dadangnh dadangnh requested a review from a team as a code owner February 21, 2025 01:02
Copy link

coderabbitai bot commented Feb 21, 2025

Walkthrough

This update refines the n8n Helm chart by raising its version and revising its description in Chart.yaml. The deployment templates for the main application, worker, and webhook now include conditional sections that add deployment labels and annotations when specified. In addition, the values.yaml file has been extended with new configuration options for custom annotations and labels on both deployments and pods.

Changes

File(s) Change Summary
charts/n8n/Chart.yaml Updated chart version from 1.1.0 to 1.2.0 and modified the annotation description from "Add environment settings to worker deployment" to "Add support to add custom deployment annotations and labels".
charts/n8n/templates/deployment*.yaml Added conditional blocks to include deployment labels and annotations using .Values.main, .Values.worker, and .Values.webhook if defined.
charts/n8n/values.yaml Introduced new configuration options: deploymentAnnotations, deploymentLabels, podAnnotations, and podLabels for the main, worker, and webhook deployments.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Helm
    participant Kubernetes
    User->>Helm: Run helm install/upgrade with custom values
    Helm->>Helm: Render templates (evaluate conditionals for labels/annotations)
    Helm->>Kubernetes: Submit deployment manifests with custom metadata
    Kubernetes-->>User: Confirm deployment creation
Loading

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 (6)
charts/n8n/templates/deployment.yaml (2)

7-9: Ensure Correct Indentation for Main Deployment Labels
The conditional block for including custom deployment labels using
  {{- if .Values.main.deploymentLabels }}
  {{- toYaml .Values.main.deploymentLabels | nindent 4 }}
  {{- end }}
is well implemented. Please confirm that the rendered YAML maintains the proper structure. (Note: YAML lint warnings here can be false positives due to Helm templating.)

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 7-7: wrong indentation: expected 2 but found 4

(indentation)


[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


10-13: Ensure Correct Indentation for Main Deployment Annotations
The new block for deployment annotations
  {{- if .Values.main.deploymentAnnotations }}
  annotations:
  {{- toYaml .Values.main.deploymentAnnotations | nindent 4 }}
  {{- end }}
is correct. Please verify that the final output YAML nests the annotations at the intended level.

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

8-10: Ensure Correct Indentation for Worker Deployment Labels
The addition of the conditional block for worker.deploymentLabels (lines 8–10) uses toYaml with nindent 4 appropriately. Confirm that the rendered YAML is correctly indented given the block’s context.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


11-14: Ensure Correct Indentation for Worker Deployment Annotations
The block adding deployment annotations for the worker (lines 11–14) appears well structured. As with the main deployment block, verify that the final YAML output meets your requirements—ignoring potential YAML lint false positives.

charts/n8n/templates/deployment.webhook.yaml (2)

10-12: Ensure Correct Indentation for Webhook Deployment Labels
The new conditional block for webhook.deploymentLabels (lines 10–12) is implemented similarly to the other components. Please double-check the rendered YAML for proper structure and spacing.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)


[warning] 12-12: wrong indentation: expected 2 but found 4

(indentation)


13-16: Ensure Correct Indentation for Webhook Deployment Annotations
The block adding deployment annotations (lines 13–16) is clear and consistent with the other template changes. As always, validate the final produced YAML format.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d3932f and 0f83b68.

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

[warning] 7-7: wrong indentation: expected 2 but found 4

(indentation)


[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)

charts/n8n/templates/deployment.webhook.yaml

[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)


[warning] 12-12: wrong indentation: expected 2 but found 4

(indentation)

charts/n8n/templates/deployment.worker.yaml

[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)

🔇 Additional comments (5)
charts/n8n/Chart.yaml (2)

3-3: Chart Version Updated
The chart version has been bumped from 1.1.0 to 1.2.0. This correctly signals the release of the new features.


37-37: Updated Description for Deployment Metadata Enhancements
The annotation description now reads “Add support to add custom deployment annotations and labels,” which clearly describes the enhancement.

charts/n8n/values.yaml (3)

149-157: Main Service Deployment and Pod Metadata Configurations Added
New keys have been introduced for the main service:
 • deploymentAnnotations: {}
 • deploymentLabels: {}
 • podAnnotations: {}
 • podLabels: {}
These additions are clear, use default empty dictionaries for backward compatibility, and should be correctly picked up by your templates.


340-347: Worker Metadata Configurations Introduced
The worker section now includes:
 • deploymentAnnotations: {}
 • deploymentLabels: {}
 • podAnnotations: {}
 • podLabels: {}
These changes mirror the main service configuration and increase consistency.


527-534: Webhook Metadata Configurations Introduced
The new configuration options for the webhook section enable custom deployment annotations and labels as well as pod metadata overrides. This addition enhances flexibility while keeping backward compatibility.

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.

1 participant