🐞 Fix: ClickHouse Operator drops container-level securityContext
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- go, kubernetes
- Domain
- devops, infrastructure
Research direction
Start by tracing reconciliation from spec.templates.podTemplates[].spec.containers[] to the generated Pod spec, focusing on where container fields are copied or omitted. Reproduce the issue with the ClickHouseInstallation example and inspect the generated Pod using kubectl and yq. Done means the defined container-level securityContext is preserved, while Pods without it remain unchanged.
Written by the indexing model from the issue text.
Description
Problem
The ClickHouse Operator currently drops container-level securityContext fields defined in:
spec.templates.podTemplates[].spec.containers[].securityContext
While pod-level securityContext is applied correctly, Kubernetes does NOT inherit several critical security fields from the pod to the container.
According to Kubernetes documentation, the following fields must be set per container and are not inherited from the pod:
allowPrivilegeEscalationcapabilitiesprivilegedseccompProfile
Reference:
https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
Because the operator drops container-level settings, users cannot run ClickHouse under Pod Security Admission (restricted) or equivalent security policies.
This is a functional bug, not a feature request.
Impact
This behavior causes:
- Admission failures in PSA
restrictedclusters - Inability to enforce:
allowPrivilegeEscalation: falsecapabilities.drop: ["ALL"]seccompProfile: RuntimeDefault
- Security / compliance violations in:
- GKE, EKS, AKS
- Gatekeeper / Kyverno enforced clusters
- Helm charts (e.g. SigNoz) unable to harden ClickHouse containers
Expected Behavior
Container-level securityContext defined in ClickHouseInstallation should be preserved and propagated to the generated Pod.
Example ClickHouseInstallation
spec:
templates:
podTemplates:
- name: pod-template
spec:
containers:
- name: clickhouse
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefault
Expected Pod Output
containers:
- name: clickhouse
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
Actual Behavior
Helm renders the ClickHouseInstallation correctly
ClickHouse Operator omits containers[].securityContext
The resulting Pod contains:
securityContext: null
Reproduction Steps
Tested locally using Minikube with SigNoz and ClickHouse Operator.
- Verify Pod Does Not Contain Container-Level securityContext
kubectl get pod chi-signoz-clickhouse-cluster-0-0-0 -n signoz -o yaml \ | yq '.spec.containers[].securityContext'
Output:
null
- Verify Helm Values Are Correct
helm get values signoz -n signoz
- Container-level securityContext is present in Helm values
- ClickHouseInstallation resource is rendered correctly
- The field is dropped only after operator reconciliation
Scope of Change
Read container-level securityContext from:
podTemplates[].spec.containers[]
Propagate it verbatim into the generated Pod spec
No behavior change for users not defining container-level securityContext
Fully backward compatible
Why Pod-Level securityContext Is Not Sufficient
Pod-level securityContext cannot replace container-level security fields required by Kubernetes security enforcement.
Kubernetes explicitly requires container-level configuration for:
allowPrivilegeEscalation
capabilities
privileged
seccompProfile
Without this fix, ClickHouse cannot comply with modern Kubernetes security standards.
- Dominant language
- Go
- Stars
- 2.6k
- Forks
- 579
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Altinity/clickhouse-operator
-
Counter metrics are missing the conventional _total suffixPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Altinity/clickhouse-operator#2093 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
Altinity/clickhouse-operator#2107 ·
Maintainers usually reply within 1 day
-
Recover reconciles from recoverAbortedReconcileOnPodReady ignores readiness of service selector labelsPossibly taken @Tyagiquamar claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Altinity/clickhouse-operator#2106 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 18/100
Altinity/clickhouse-operator#2105 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Altinity/clickhouse-operator#2098 ·
Maintainers usually reply within 1 day
All issues in Altinity/clickhouse-operator
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
ViewData can pair the in-flight proposal with the prepared flag of another proposalPossibly taken @HagarMeir claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hyperledger/SmartBFT#710 ·
Maintainers usually reply within 1 day
-
agent-butler-finding chore
Difficulty 1/5 Under an hour Newbie friendliness 90/100
jordansmall/spindrift#5575 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
open-telemetry/opentelemetry-go-compile-instrumentation#1512 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
OpenPrinting/go-mfp#124 ·
Maintainers usually reply within 1 day