Skip to content

Commit 4629ff9

Browse files
committed
fix(hosting): close upgrade gaps found in adversarial review of the ClickHouse chart
Keeps existing self-hosted deployments working without manual steps: - Default resource requests/limits match the preset the Bitnami subchart applied, so the ClickHouse pod doesn't silently become BestEffort. - nodeSelector, tolerations, and affinity pass through to the StatefulSet for deployments that schedule ClickHouse onto dedicated nodes. - Optional volumePermissions init container fixes data-volume ownership on storage without fsGroup support (NFS, hostPath). - The helm test reads the password from the datastore secret instead of the usually-empty values key, and the pinned-password restart checksum is omitted when the password is auto-generated. - Docs cover updating a pinned CLICKHOUSE_IMAGE_TAG to an official tag and the GitOps existingClaim step in more detail.
1 parent 228c4a3 commit 4629ff9

5 files changed

Lines changed: 81 additions & 6 deletions

File tree

docs/self-hosting/docker.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,13 @@ We patch the latest released version line only, so keep an eye on new releases t
364364
365365
You can also lock the versions of the bundled services, for example with `CLICKHOUSE_IMAGE_TAG`. If you do, or if you bring your own ClickHouse via `CLICKHOUSE_URL`, note that Trigger.dev requires ClickHouse 25.8 or newer.
366366
367+
<Note>
368+
The bundled ClickHouse now uses the official `clickhouse/clickhouse-server` image. Your existing
369+
data volume carries over automatically. If you previously pinned `CLICKHOUSE_IMAGE_TAG` to a
370+
Bitnami tag (for example `25.7.5-debian-12-r0`), update it to an official image tag such as
371+
`26.2` — Bitnami tags don't exist in the official repository.
372+
</Note>
373+
367374
<Note>
368375
Trigger.dev 4.5.0 is the last version we officially support for running v3 (SDK v3) tasks. If
369376
you still have v3 tasks, pin `TRIGGER_IMAGE_TAG` to exactly `v4.5.0` or [migrate to

docs/self-hosting/kubernetes.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,14 @@ redis:
286286
automatically adopts the existing data volume, so no manual migration is needed. If you render
287287
manifests without cluster access (for example with GitOps tools that use `helm template`), set
288288
`clickhouse.persistence.existingClaim` to the old PVC name
289-
(`data-<release>-clickhouse-shard0-0`) to keep your data.
289+
(`data-<release>-clickhouse-shard0-0`) to keep your data — auto-detection can't run there, and
290+
skipping this starts ClickHouse on a fresh empty volume.
291+
</Note>
292+
293+
<Note>
294+
On storage that doesn't support `fsGroup` ownership changes (for example NFS or hostPath), set
295+
`clickhouse.volumePermissions.enabled: true` so a one-time init container fixes the data
296+
volume's ownership for the non-root ClickHouse server.
290297
</Note>
291298

292299
**Direct configuration:**

hosting/k8s/helm/templates/clickhouse.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ spec:
4848
metadata:
4949
annotations:
5050
checksum/config: {{ printf "%s\n%s" (include "trigger-v4.clickhouse.dataPathsConfig" .) (.Values.clickhouse.configdFiles | toYaml) | sha256sum }}
51+
{{- /* Restart on pinned-password changes; when the password is
52+
auto-generated it lives in the retained datastore secret and
53+
never rotates on upgrade, so there is nothing to hash. */}}
54+
{{- if .Values.clickhouse.auth.password }}
5155
checksum/secret: {{ .Values.clickhouse.auth.password | sha256sum }}
56+
{{- end }}
5257
{{- with .Values.clickhouse.podAnnotations }}
5358
{{- toYaml . | nindent 8 }}
5459
{{- end }}
@@ -63,6 +68,19 @@ spec:
6368
securityContext:
6469
{{- toYaml . | nindent 8 }}
6570
{{- end }}
71+
{{- if .Values.clickhouse.volumePermissions.enabled }}
72+
initContainers:
73+
- name: volume-permissions
74+
image: "{{ .Values.global.imageRegistry | default .Values.clickhouse.volumePermissions.image.registry }}/{{ .Values.clickhouse.volumePermissions.image.repository }}:{{ .Values.clickhouse.volumePermissions.image.tag }}"
75+
imagePullPolicy: {{ .Values.clickhouse.volumePermissions.image.pullPolicy }}
76+
command: ["sh", "-c", "chown -R 101:101 /var/lib/clickhouse"]
77+
securityContext:
78+
runAsUser: 0
79+
runAsNonRoot: false
80+
volumeMounts:
81+
- name: data
82+
mountPath: /var/lib/clickhouse
83+
{{- end }}
6684
containers:
6785
- name: clickhouse
6886
{{- with .Values.clickhouse.securityContext }}
@@ -134,6 +152,18 @@ spec:
134152
mountPath: /etc/clickhouse-server/config.d/{{ $filename }}
135153
subPath: {{ $filename }}
136154
{{- end }}
155+
{{- with .Values.clickhouse.nodeSelector }}
156+
nodeSelector:
157+
{{- toYaml . | nindent 8 }}
158+
{{- end }}
159+
{{- with .Values.clickhouse.affinity }}
160+
affinity:
161+
{{- toYaml . | nindent 8 }}
162+
{{- end }}
163+
{{- with .Values.clickhouse.tolerations }}
164+
tolerations:
165+
{{- toYaml . | nindent 8 }}
166+
{{- end }}
137167
volumes:
138168
- name: config
139169
configMap:

hosting/k8s/helm/templates/tests/test-clickhouse.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ spec:
1212
containers:
1313
- name: test-clickhouse
1414
image: curlimages/curl:8.14.1
15+
env:
16+
- name: CLICKHOUSE_USER
17+
value: {{ .Values.clickhouse.auth.username | quote }}
18+
- name: CLICKHOUSE_PASSWORD
19+
valueFrom:
20+
secretKeyRef:
21+
name: {{ .Values.clickhouse.auth.existingSecret | default (include "trigger-v4.datastore.secretName" .) }}
22+
key: {{ .Values.clickhouse.auth.existingSecretKey | default "clickhouse-admin-password" }}
1523
command: ['sh', '-c']
1624
args:
1725
- |
1826
echo "Testing ClickHouse HTTP interface..."
19-
curl -f --user "{{ .Values.clickhouse.auth.username }}:{{ .Values.clickhouse.auth.password }}" "http://{{ include "trigger-v4.clickhouse.hostname" . }}:{{ .Values.clickhouse.service.ports.http }}/ping"
27+
curl -f --user "$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD" "http://{{ include "trigger-v4.clickhouse.hostname" . }}:{{ .Values.clickhouse.service.ports.http }}/ping"
2028
echo "ClickHouse test completed successfully"
21-
{{- end }}
29+
{{- end }}

hosting/k8s/helm/values.yaml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,22 @@ clickhouse:
667667
runAsUser: 101
668668
runAsGroup: 101
669669

670+
# One-time root init container that chowns the data volume to the ClickHouse
671+
# uid. Only needed on storage that doesn't support fsGroup ownership changes
672+
# (e.g. NFS, hostPath); on such storage a data volume carried over from the
673+
# Bitnami-based chart is otherwise unreadable by the non-root server.
674+
volumePermissions:
675+
enabled: false
676+
image:
677+
registry: docker.io
678+
repository: busybox
679+
tag: "1.35"
680+
pullPolicy: IfNotPresent
681+
682+
nodeSelector: {}
683+
tolerations: []
684+
affinity: {}
685+
670686
service:
671687
type: ClusterIP
672688
ports:
@@ -689,9 +705,16 @@ clickhouse:
689705

690706
## ClickHouse resource requests and limits
691707
## ref: http://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
692-
## ClickHouse can be very resource intensive. Setting explicit limits and
693-
## requests is strongly recommended for production (see values-production-example.yaml).
694-
resources: {}
708+
## ClickHouse can be very resource intensive. The defaults below match the
709+
## resource preset the chart previously applied; size them to your workload
710+
## for production (see values-production-example.yaml).
711+
resources:
712+
requests:
713+
cpu: 1000m
714+
memory: 3Gi
715+
limits:
716+
cpu: 3000m
717+
memory: 6Gi
695718

696719
livenessProbe:
697720
enabled: true

0 commit comments

Comments
 (0)