Skip to content

feat(chart): add global chart metadata support#130

Open
kamiKAC wants to merge 1 commit into
n8n-io:mainfrom
kamiKAC:feat/common-labels-and-annotations
Open

feat(chart): add global chart metadata support#130
kamiKAC wants to merge 1 commit into
n8n-io:mainfrom
kamiKAC:feat/common-labels-and-annotations

Conversation

@kamiKAC
Copy link
Copy Markdown

@kamiKAC kamiKAC commented May 12, 2026

Pull Request

Description

Adds chart-wide support for commonLabels and commonAnnotations so users can apply consistent metadata across rendered resources from a single values entry.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Example/configuration update
  • CI/CD improvements

Related Issues

Closes #120

Changes Made

  • Added commonLabels and commonAnnotations values and schema definitions.
  • Applied common labels/annotations across core chart resources (Deployments, Services, Ingresses, HPAs/ScaledObjects, RBAC, PDB/PVC, ConfigMap/Secrets, etc.).
  • Added pod-template annotation support in deployment templates.
  • Updated charts/n8n/examples/minimal.yaml and examples README to show usage.

Testing Performed

Chart Validation

  • helm lint charts/n8n passes
  • ./scripts/validate-examples.sh passes
  • Template rendering works with all examples

Deployment Testing (if applicable)

  • Tested with minimal configuration
  • Tested with production configuration
  • Tested upgrade path from previous version
  • All pods start successfully
  • Application is accessible

Specific Testing for Changes

Describe any specific testing you performed for your changes:

  • Rendered templates with multiple example values files (including production-style example) and verified metadata appears in expected resources.
  • Verified pod-level annotations are rendered in all deployment variants (main, worker, webhook-processor).

Breaking Changes

If this includes breaking changes, describe what they are and provide migration instructions:

  • None.

Documentation Updates

  • Updated Chart.yaml version (if needed)
  • Updated CHANGELOG.md
  • Updated README.md (if needed)
  • Updated examples (if needed)
  • Updated CONTRIBUTING.md (if needed)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added examples that demonstrate the changes (if applicable)
  • All new and existing tests pass

Screenshots (if applicable)

N/A

Additional Notes

This change is additive and backward-compatible. Existing chart users are unaffected unless they set commonLabels and/or commonAnnotations.


Summary by cubic

Adds global metadata to the n8n Helm chart via commonLabels and commonAnnotations, applied across all rendered resources and pod templates. This reduces repetition for governance tags and tooling (e.g., Stakater Reloader).

  • New Features
    • Added commonLabels and commonAnnotations to values.yaml and values.schema.json (both default to {}).
    • Applied commonLabels through the shared labels helper so all resources inherit them.
    • Applied commonAnnotations to resource metadata and pod template annotations; merged with resource-specific annotations for Ingress, Service, and ServiceAccount.
    • Included a usage example in examples/minimal.yaml and updated the examples README.

Written for commit f0fffc6. Summary will update on new commits.

@kamiKAC kamiKAC changed the title feat: add global chart metadata support feat(chart): add global chart metadata support May 12, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 27 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/templates/serviceaccount.yaml">

<violation number="1" location="charts/n8n/templates/serviceaccount.yaml:10">
P2: The ServiceAccount annotations are rendered from multiple maps without collision handling, so duplicate keys can be emitted and silently override each other.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant Helm as Helm User
    participant Tpl as Chart Templates
    participant Helper as _helpers.tpl
    participant Config as ConfigMap
    participant MainDep as Deployment (Main)
    participant WorkerDep as Deployment (Worker)
    participant WebhookDep as Deployment (Webhook)
    participant HPA as HPA (Main/Worker/Webhook)
    participant Ingress as Ingress
    participant Service as Service
    participant SvcAcc as ServiceAccount
    participant Secrets as Secrets
    participant PVC as PVC
    participant PDB as PDB
    participant NetPol as NetworkPolicy
    participant RBAC as Role/RoleBinding
    participant ScaledObj as ScaledObject (KEDA)
    participant TestPod as Helm Test Pod
    participant Schema as values.schema.json

    Note over Helm,Schema: NEW: Global Metadata Injection Flow

    Helm->>Tpl: helm install/upgrade with values.yaml

    alt commonLabels defined (e.g., my-platform.io/team: automation)
        Note over Tpl,Helper: Step 1: Labels injected via shared helper
        Tpl->>Helper: include "n8n.labels"
        Helper->>Helper: emit standard labels + commonLabels
        Helper-->>Tpl: rendered label set

        Tpl->>Config: metadata.labels = n8n.labels
        Tpl->>MainDep: metadata.labels = n8n.labels + component:main
        Tpl->>WorkerDep: metadata.labels = n8n.labels + component:worker
        Tpl->>WebhookDep: metadata.labels = n8n.labels + component:webhook
        Tpl->>HPA: metadata.labels = n8n.labels
        Tpl->>Ingress: metadata.labels = n8n.labels
        Tpl->>Service: metadata.labels = n8n.labels
        Tpl->>SvcAcc: metadata.labels = n8n.labels
        Tpl->>Secrets: metadata.labels = n8n.labels
        Tpl->>PVC: metadata.labels = n8n.labels
        Tpl->>PDB: metadata.labels = n8n.labels
        Tpl->>NetPol: metadata.labels = n8n.labels
        Tpl->>RBAC: metadata.labels = n8n.labels
        Tpl->>ScaledObj: metadata.labels = n8n.labels
        Tpl->>TestPod: metadata.labels = n8n.labels
    end

    alt commonAnnotations defined (e.g., secret.reloader.stakater.com/auto: true)
        Note over Tpl: Step 2: Annotations applied at resource level
        Tpl->>Config: metadata.annotations = commonAnnotations
        Tpl->>MainDep: metadata.annotations = commonAnnotations
        Tpl->>MainDep: spec.template.metadata.annotations = commonAnnotations + checksum + podAnnotations
        Tpl->>WorkerDep: metadata.annotations = commonAnnotations
        Tpl->>WorkerDep: spec.template.metadata.annotations = commonAnnotations + checksum + podAnnotations
        Tpl->>WebhookDep: metadata.annotations = commonAnnotations
        Tpl->>WebhookDep: spec.template.metadata.annotations = commonAnnotations + checksum + podAnnotations
        Tpl->>HPA: metadata.annotations = commonAnnotations
        Tpl->>PVC: metadata.annotations = commonAnnotations
        Tpl->>PDB: metadata.annotations = commonAnnotations
        Tpl->>NetPol: metadata.annotations = commonAnnotations
        Tpl->>Secrets: metadata.annotations = commonAnnotations
        Tpl->>ScaledObj: metadata.annotations = commonAnnotations
        Tpl->>RBAC: metadata.annotations = commonAnnotations
        Tpl->>TestPod: metadata.annotations = commonAnnotations
    end

    Note over Tpl,Service: Step 3: Specific merge for certain resources
    alt Ingress (main and webhook)
        Tpl->>Ingress: metadata.annotations = commonAnnotations + ingress-specific annotations
    end
    alt Service (main and webhook)
        Tpl->>Service: metadata.annotations = commonAnnotations + merged service.annotations
    end
    alt ServiceAccount
        Tpl->>SvcAcc: metadata.annotations = commonAnnotations + awsRoleArn + serviceAccount.annotations
    end

    Note over Tpl,Schema: Validation step
    Tpl->>Schema: validate commonLabels: object with string values
    Tpl->>Schema: validate commonAnnotations: object with string values
    Schema-->>Tpl: pass/fail

    Note over Helm: Final output: all Kubernetes resources include<br/>global commonLabels and commonAnnotations
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

labels:
{{- include "n8n.labels" . | nindent 4 }}
annotations:
{{- with .Values.commonAnnotations }}
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 12, 2026

Choose a reason for hiding this comment

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

P2: The ServiceAccount annotations are rendered from multiple maps without collision handling, so duplicate keys can be emitted and silently override each other.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At charts/n8n/templates/serviceaccount.yaml, line 10:

<comment>The ServiceAccount annotations are rendered from multiple maps without collision handling, so duplicate keys can be emitted and silently override each other.</comment>

<file context>
@@ -4,9 +4,16 @@ kind: ServiceAccount
+  labels:
+    {{- include "n8n.labels" . | nindent 4 }}
   annotations:
+    {{- with .Values.commonAnnotations }}
+    {{- toYaml . | nindent 4 }}
+    {{- end }}
</file context>
Fix with Cubic

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.

[Feature]: Support commonLabels and commonAnnotations across all chart resources

1 participant