Allow more customization for security contexts - #160
Open
albundy83 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 7 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/deployment-worker.yaml">
<violation number="1" location="charts/n8n/templates/deployment-worker.yaml:38">
P1: SecurityContext key rename has no backward-compatibility shim, so existing user-provided security settings under the old `securityContext` key are silently dropped during chart upgrades.</violation>
</file>
<file name="charts/n8n/values.schema.json">
<violation number="1" location="charts/n8n/values.schema.json:229">
P2: HPA settings were moved under `hpa.main`, but the `hpa` schema object remains open so legacy top-level keys can still validate and silently become no-ops.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Helm as Helm Values
participant Render as Helm Template Engine
participant Dep as Deployment (Main)
participant WorkerDep as Deployment (Worker)
participant WebhookDep as Deployment (Webhook Processor)
participant Sidecar as TaskRunner Sidecar Container
participant KubePod as Kubernetes Pod
participant KubeContainer as Container Runtime
Note over Helm,KubeContainer: Security Context Configuration Flow
Helm->>Render: NEW: .Values.podSecurityContext (map)
Helm->>Render: NEW: .Values.containerSecurityContext (map)
Helm->>Render: NEW: .Values.webhookProcessor.podSecurityContext (map)
Helm->>Render: NEW: .Values.webhookProcessor.containerSecurityContext (map)
Helm->>Render: NEW: .Values.taskRunners.containerSecurityContext (map)
Render->>Render: toYaml: pod-level contexts
Render->>Dep: podSecurityContext rendered
Render->>WorkerDep: podSecurityContext rendered
Render->>WebhookDep: podSecurityContext rendered
Render->>Render: toYaml: container-level contexts
Render->>Dep: containerSecurityContext rendered
Render->>WorkerDep: containerSecurityContext rendered
Render->>WebhookDep: containerSecurityContext rendered
Render->>Sidecar: taskRunners.containerSecurityContext rendered
Dep->>KubePod: Apply podSecurityContext (fsGroup, runAsUser, runAsGroup, seccompProfile)
KubePod->>KubeContainer: Apply containerSecurityContext (capabilities.drop, readOnlyRootFS, runAsUser)
WorkerDep->>KubePod: Same pattern: podSecurityContext
KubePod->>KubeContainer: Same pattern: containerSecurityContext
WebhookDep->>KubePod: Same pattern: webhookProcessor.podSecurityContext
KubePod->>KubeContainer: Same pattern: webhookProcessor.containerSecurityContext
Sidecar->>KubeContainer: Apply taskRunners.containerSecurityContext (distroless-ready)
Note over KubeContainer: NEW: Each component independently configurable<br/>Allows per-component seccomp, runAsGroup, capabilities
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| "type": { "type": "string" }, | ||
| "port": { "type": "integer", "minimum": 1, "maximum": 65535 }, | ||
| "annotations": { "type": "object", "additionalProperties": true }, | ||
| "main": { |
Contributor
There was a problem hiding this comment.
P2: HPA settings were moved under hpa.main, but the hpa schema object remains open so legacy top-level keys can still validate and silently become no-ops.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At charts/n8n/values.schema.json, line 229:
<comment>HPA settings were moved under `hpa.main`, but the `hpa` schema object remains open so legacy top-level keys can still validate and silently become no-ops.</comment>
<file context>
@@ -200,6 +226,18 @@
"type": { "type": "string" },
"port": { "type": "integer", "minimum": 1, "maximum": 65535 },
"annotations": { "type": "object", "additionalProperties": true },
+ "main": {
+ "type": "object",
+ "properties": {
</file context>
Signed-off-by: Grégoire Bellon-Gervais <gregoire.bellon-gervais@docaposte.fr>
albundy83
force-pushed
the
improve-securitycontext
branch
from
July 7, 2026 13:55
fab2879 to
2bc91bd
Compare
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
Allow a more flexible way to configure security context accross the differents containers.
Allow also to achieve the hardening recommandation here
Description
Brief description of the changes and their purpose.
Type of Change
Related Issues
Fixes # (issue)
Relates to # (issue)
Changes Made
Remove
SecurityContextand split it inpodSecurityContextandcontainerSecurityContextTesting Performed
I have fully deployed it and also be able to set custom user and group id for runners.
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:
Yes. The old
SecurityContexthas been split intopodSecurityContextandcontainerSecurityContext.The best approach is to remove
SecurityContext, as it will be silently ignored, and replace it withpodSecurityContextand/orcontainerSecurityContext, which provide more granular configuration and customization capabilities.Or let the default values do the job.. :)
Documentation Updates
Checklist
Screenshots (if applicable)
Add screenshots to help explain your changes.
Additional Notes
Any additional information that reviewers should know.
Summary by cubic
Split the old
securityContextinto pod-level and container-level settings across main, worker, webhook-processor, and task-runner sidecars to enable stricter hardening and support distroless runners.New Features
.Values.podSecurityContextand.Values.containerSecurityContextfor main and worker..Values.webhookProcessor.podSecurityContextand.Values.webhookProcessor.containerSecurityContext..Values.taskRunners.containerSecurityContext.toYamlfor full control ofseccompProfile,runAs*,capabilities, andreadOnlyRootFilesystem.values.yamlmirror previous behavior;readOnlyRootFilesystemremains false. Examples updated to usepodSecurityContextwithrunAsGroupandseccompProfile.Migration
securityContext.*(includingenabled) with:podSecurityContextandcontainerSecurityContext(main/worker)webhookProcessor.podSecurityContextand.containerSecurityContexttaskRunners.containerSecurityContextrunAs*,capabilities.drop: [ALL], andseccompProfile: RuntimeDefault.runAsUser/runAsGroupto65532.Written for commit 2bc91bd. Summary will update on new commits.