Skip to content

Commit f95ad01

Browse files
committed
fix(helm): auto-run the clickhouse chown init when adopting a bitnami volume
Upgrading the bundled ClickHouse from the Bitnami subchart to the official image adopts the old data volume, whose files are owned by the previous uid. The official server runs non-root (uid 101), so on storage where fsGroup can't relabel the volume (hostPath, NFS, local-path - common for self-hosters) it crashes with 'cd: /var/lib/clickhouse/data/: Permission denied'. Run the one-time chown init automatically whenever a volume is adopted (existingClaim set, explicitly or auto-detected); fresh installs create their own data and skip it, and volumePermissions.enabled still forces it. Verified live in kind: a bitnami->official upgrade on local-path storage now comes up with data and auth intact, with no manual flag.
1 parent fbf811c commit f95ad01

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

docs/self-hosting/kubernetes.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,11 @@ redis:
345345
</Note>
346346

347347
<Note>
348-
On storage that doesn't support `fsGroup` ownership changes (for example NFS or hostPath), set
349-
`clickhouse.volumePermissions.enabled: true` so a one-time init container fixes the data
350-
volume's ownership for the non-root ClickHouse server.
348+
When a volume is adopted from the Bitnami-based chart, a one-time init container fixes its
349+
ownership for the non-root ClickHouse server. This runs automatically on `helm upgrade` (and
350+
when you set `clickhouse.persistence.existingClaim`), so storage that doesn't support `fsGroup`
351+
ownership changes (NFS, hostPath, local-path) works without manual steps. Set
352+
`clickhouse.volumePermissions.enabled: true` to force it in other cases.
351353
</Note>
352354

353355
**Direct configuration:**

hosting/k8s/helm/templates/clickhouse.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ spec:
6868
securityContext:
6969
{{- toYaml . | nindent 8 }}
7070
{{- end }}
71-
{{- if .Values.clickhouse.volumePermissions.enabled }}
71+
{{- /* Adopting a volume from the Bitnami-based chart (auto-detected or an
72+
explicit existingClaim) means the data is owned by the old uid. On
73+
storage where fsGroup can't relabel it (hostPath, NFS, local-path),
74+
the non-root server can't read it, so run the chown init container
75+
automatically. Fresh installs create their own data and skip it. */}}
76+
{{- if or .Values.clickhouse.volumePermissions.enabled $existingClaim }}
7277
initContainers:
7378
- name: volume-permissions
7479
image: "{{ .Values.global.imageRegistry | default .Values.clickhouse.volumePermissions.image.registry }}/{{ .Values.clickhouse.volumePermissions.image.repository }}:{{ .Values.clickhouse.volumePermissions.image.tag }}"

0 commit comments

Comments
 (0)