feat(chart): add global chart metadata support#130
Open
kamiKAC wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
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 }} |
Contributor
There was a problem hiding this comment.
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>
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 chart-wide support for
commonLabelsandcommonAnnotationsso users can apply consistent metadata across rendered resources from a single values entry.Type of Change
Related Issues
Closes #120
Changes Made
commonLabelsandcommonAnnotationsvalues and schema definitions.charts/n8n/examples/minimal.yamland examples README to show usage.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:
Breaking Changes
If this includes breaking changes, describe what they are and provide migration instructions:
Documentation Updates
Checklist
Screenshots (if applicable)
N/A
Additional Notes
This change is additive and backward-compatible. Existing chart users are unaffected unless they set
commonLabelsand/orcommonAnnotations.Summary by cubic
Adds global metadata to the
n8nHelm chart viacommonLabelsandcommonAnnotations, applied across all rendered resources and pod templates. This reduces repetition for governance tags and tooling (e.g., Stakater Reloader).commonLabelsandcommonAnnotationstovalues.yamlandvalues.schema.json(both default to{}).commonLabelsthrough the shared labels helper so all resources inherit them.commonAnnotationsto resource metadata and pod template annotations; merged with resource-specific annotations forIngress,Service, andServiceAccount.examples/minimal.yamland updated the examples README.Written for commit f0fffc6. Summary will update on new commits.