feat(chart): add extraContainers for arbitrary sidecar injection#138
feat(chart): add extraContainers for arbitrary sidecar injection#138Vishesh-Gupta wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
No issues found across 6 files
Architecture diagram
sequenceDiagram
participant Admin as Operator/Admin
participant Values as values.yaml
participant Schema as values.schema.json
participant Helm as Helm Template Engine
participant DeployMain as Deployment-main.yaml
participant DeployWorker as Deployment-worker.yaml
participant DeployWebhook as Deployment-webhook-processor.yaml
participant Pod as Pod Spec (main/worker/webhook)
participant N8nContainer as n8n Container
participant TaskRunner as Task Runner Sidecar (optional)
participant ExtraContainers as Extra Sidecar Containers
Note over Admin,ExtraContainers: PR: Adds extraContainers for arbitrary sidecar injection
Admin->>Values: Set extraContainers array in values.yaml
Values->>Schema: Validate against new schema definition
Schema-->>Values: Validation passes (array of objects)
Helm->>Values: Read extraContainers value
Helm->>DeployMain: Process deployment-main.yaml template
Helm->>DeployWorker: Process deployment-worker.yaml template
Helm->>DeployWebhook: Process deployment-webhook-processor.yaml template
Note over DeployMain,DeployWebhook: Each deployment follows the same pattern
DeployMain->>Helm: Execute tpl(toYaml .) on extraContainers
Note over Helm: tpl processes {{ .Release.Name }} etc. in container fields
Helm-->>DeployMain: Rendered YAML for extra containers
DeployMain->>Pod: Append containers after:
Pod->>N8nContainer: Container 1 (always present)
alt Task runner enabled
Pod->>TaskRunner: Container 2 (optional)
end
Pod->>ExtraContainers: Container N+1 (new sidecar from extraContainers)
alt Shared volumes needed
ExtraContainers->>ExtraContainers: Mount volumes via extraVolumeMounts
Note over ExtraContainers: Combines with extraVolumes for shared storage
end
Helm-->>DeployMain: Return complete pod spec
Helm-->>DeployWorker: Return complete pod spec
Helm-->>DeployWebhook: Return complete pod spec
Admin->>Helm: helm lint / helm template (verify output)
Helm-->>Admin: Validated template with sidecars injected
…eAccount.automountServiceAccountToken Three pod-spec extension points, all applied to main, worker, and webhook-processor deployments via the existing global-value pattern: - extraInitContainers: list of init containers prepended to each pod spec. Supports the K8s 1.29+ native-sidecar pattern (entries with restartPolicy: Always). Values are passed through Helm tpl, matching the convention established by extraContainers (n8n-io#138). - dnsPolicy + dnsConfig: pod-level DNS policy and configuration, mapping directly to the Kubernetes PodSpec fields. Useful for routing resolution through a sidecar resolver, overriding search domains, or tuning ndots. - serviceAccount.automountServiceAccountToken: pod-spec toggle for the ServiceAccount token automount. Defaults to unset (preserves K8s default behaviour); set to false to remove the projected token from workloads that don't talk to the Kubernetes API. Signed-off-by: Cameron Attard <cameron.attard@siteminder.com>
krider2010
left a comment
There was a problem hiding this comment.
Nice addition, this is a clean non-breaking extension and lines up with the existing extraVolumes/extraEnv pattern. A couple of things I'd like to see before I approve:
-
The new table row says "Additional sidecar containers on all n8n pods" but the prose section below correctly scopes it to main, worker, and webhook-processor (not migration jobs etc.). Can you tighten the one-liner to match? Small thing, but it'll save someone a confused issue later.
-
None of the CI example values files exercise
extraContainers, so the rendered-template CI won't cover this on every run. Could you add a minimal entry to one of the existing values files undercharts/n8n/ci/(or a newextraContainers-values.yaml) so we lock the behaviour in?
Couple of FYI-only things, not blocking:
extraInitContainersis the natural sibling here — sametpl ... $pattern would work. Not asking you to add it in this PR, just flagging as a likely follow-up.- The schema is loose (
items: { type: "object" }) which is the right call — full container-spec validation in Helm is more pain than it's worth, and the API server catches malformed entries.
Otherwise looks good — placement after the task-runner sidecar is correct, tpl ... $ gives the right root context, indentation checks out.
…eAccount.automountServiceAccountToken Three pod-spec extension points, all applied to main, worker, and webhook-processor deployments via the existing global-value pattern: - extraInitContainers: list of init containers prepended to each pod spec. Supports the K8s 1.29+ native-sidecar pattern (entries with restartPolicy: Always). Values are passed through Helm tpl, matching the convention established by extraContainers (n8n-io#138). - dnsPolicy + dnsConfig: pod-level DNS policy and configuration, mapping directly to the Kubernetes PodSpec fields. Useful for routing resolution through a sidecar resolver, overriding search domains, or tuning ndots. - serviceAccount.automountServiceAccountToken: pod-spec toggle for the ServiceAccount token automount. Defaults to unset (preserves K8s default behaviour); set to false to remove the projected token from workloads that don't talk to the Kubernetes API. Signed-off-by: Cameron Attard <cameron.attard@siteminder.com>
Address review: tighten extraContainers table copy; add charts/n8n/ci/ extraContainers-values.yaml and CI helm template step (minimal overlay).
|
Thanks for the review — addressed the blocking items:
FYI acknowledgements (no code changes for these in this PR):
Let me know if you want the overlay wired to a different base example instead of |
|
Thanks! I'll review properly soon. |
Summary
extraContainersvalue so operators can inject arbitrary sidecar containers (log shippers, local proxies, exporters, etc.) without forking the chart.tplontoYamloutput so values can reference release/chart context (e.g.{{ .Release.Name }}).values.schema.jsonand document usage in the chart README.Test plan
helm lint charts/n8nhelm templatewith each example values file used in CI (minimal,minimal-with-docker,multi-main-queue,task-runners,keda-autoscaling,production-s3)helm templatesmoke test with--set-jsonfor a minimalextraContainersentrySummary by cubic
Add a top-level
extraContainersvalue to inject arbitrary sidecars on n8n pods. Adds a CI overlay to templateextraContainersagainst the minimal example to prevent regressions.tpland appends after the n8n container (and task-runner if present).values.schema.jsonand README with usage and examples.--dry-run=clientand validatescharts/n8n/ci/extraContainers-values.yamlover the minimal example.Written for commit a3d1942. Summary will update on new commits. Review in cubic