Repository navigation
helm: default to the restricted Pod Security Standard - #2174
Conversation
The operator Deployment and the CRD installation hook rendered empty pod and container security contexts, so the chart could not be installed in a namespace that enforces the restricted Pod Security Standard: the pre-install hook pod is rejected and the release fails. - podSecurityContext: runAsNonRoot with uid/gid 65534 (both images run as `nobody`, a non-numeric USER the kubelet cannot verify without a numeric runAsUser) and the RuntimeDefault seccomp profile. - operator and metrics-exporter containers: no privilege escalation, all capabilities dropped, read-only root filesystem (the only write is the IPC token to its emptyDir). - crdHook: the same pod defaults (the kubectl image runs as root by default but only talks to the API server), no privilege escalation, all capabilities dropped. dev/test_helm_chart.sh covers the defaults and dropping one with null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: drfaust92 <ilia.lazebnik@gmail.com>
793aa26 to
e3812b6
Compare
|
@DrFaust92 , thank you for the PR. It does introduce potentially breaking changes to the Helm chart defaults, so I recommend marking it BACKWARD INCOMPATIBLE in the changelog. One potential problem: hard-coded UID 65534 can prevent installation on OpenShift. OpenShift's standard restricted-v2 Security Context Constraint generally requires a UID from the namespace's allocated range. 65534 is usually outside that range, so OpenShift can reject both the pre-install Job and the operator Pod. Red Hat specifically documents how explicit UIDs outside the permitted range fail admission. While operator is typically deployed via OLM on OpenShift, it is still a concern. Maybe add a specific note to docs, so OpenShift users could override it. Another issue is that PR sets readOnlyRootFilesystem: true for both operator containers. Unlike allowPrivilegeEscalation: false, dropping capabilities, and non-root execution, a read-only root filesystem is not required by the Kubernetes Restricted Pod Security Standard. This matters because the PR itself acknowledges that disabling logtostderr can require a writable log directory. |
…enShift Drop readOnlyRootFilesystem from the container defaults: restricted does not require it, and a user who turns off logtostderr needs a writable log dir. Document nulling runAsUser/runAsGroup on OpenShift, where restricted-v2 assigns the uid from the namespace range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: drfaust92 <ilia.lazebnik@gmail.com>
|
@alex-zaitsev thanks, done in 553b45e. The changelog entry is marked BACKWARD INCOMPATIBLE and says how to run on OpenShift: set |
The chart renders empty pod and container security contexts for the operator Deployment and for the CRD installation hook, so it cannot be installed in a namespace that enforces the restricted Pod Security Standard. The
pre-installhook pod is rejected and the release fails:This sets restricted defaults in
values.yaml(the generator script leaves these keys alone, sodev/generate_helm_chart.shdoesn't need changes):altinity/clickhouse-operator:0.28.0andaltinity/metrics-exporter:0.28.0run asUSER nobody(uid/gid 65534 in their/etc/passwd). That user is not numeric, so withrunAsNonRootalone the kubelet cannot verify it and refuses to start the container;runAsUser: 65534keeps the same user and makes it verifiable.pkg/chop/ipc_token.go, default/etc/clickhouse-operator-ipc/token), which lives on the existingclickhouse-operator-ipcemptyDir, so the root filesystem can be read-only. Iflogtostderris turned off in the operator configuration, glog writes log files and needs a writable volume.registry.k8s.io/kubectlruns as root by default; the hook only talks to the API server, so it runs as 65534 too. This changes the opt-in defaults added in Add security context for crdHook to enable security policy compliance #1950 / feat(helm): add podSecurityContext and podAnnotations to crdHook Job #2009, because with the hook enabled by default the chart otherwise can't install underrestrictedat all./metricsqueries every ClickHouse host on each scrape.null.dev/test_helm_chart.shgets a "security context" section (6 checks: the pod and container defaults, the hook defaults, droppingrunAsUserwithnull, and an emptypodSecurityContext), andREADME.mdis regenerated with helm-docs. A CHANGELOG entry is added under 0.28.0 → Changed.Testing
dev/test_helm_chart.sh:PASSED 30 checks, including the README drift check. Against the0.28.0chart, the three default checks in the new section fail.helm lint --strictpasses.pod-security.kubernetes.io/enforce=restricted:0.28.0: the hook Job can't create its pod andhelm installfails with the error above.2/2 Running. Withwatch.namespaces.include: [".*"], a one-replicaClickHouseInstallationin another namespace reachesCompleted; the metrics-exporter serveschi_clickhouse_metric_*series for it and the operator servesclickhouse_operator_*metrics. Thehelm upgrade(pre-upgrade hook) also passes admission.security.ipc.mode: Secure: the operator logsIPC: Secure mode — provisioned token at /etc/clickhouse-operator-ipc/tokenwith the read-only root filesystem, and the exporter keeps serving ClickHouse metrics through/chi.This PR was prepared with an AI assistant (Claude Code) and reviewed by me.
🤖 Generated with Claude Code