Skip to content

Commit 534804a

Browse files
committed
improve clickhouse config
improve clickhouse config
1 parent ac2998d commit 534804a

File tree

6 files changed

+56
-37
lines changed

6 files changed

+56
-37
lines changed

hosting/k8s/helm/templates/clickhouse.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.clickhouse.enabled }}
1+
{{- if and .Values.clickhouse.enabled (not .Values.clickhouse.external) }}
22
apiVersion: apps/v1
33
kind: StatefulSet
44
metadata:
@@ -34,8 +34,11 @@ spec:
3434
image: "{{ .Values.clickhouse.image.registry }}/{{ .Values.clickhouse.image.repository }}:{{ .Values.clickhouse.image.tag }}"
3535
imagePullPolicy: {{ .Values.clickhouse.image.pullPolicy }}
3636
ports:
37+
- name: native
38+
containerPort: {{ .Values.clickhouse.service.ports.native }}
39+
protocol: TCP
3740
- name: http
38-
containerPort: {{ .Values.clickhouse.service.targetPort }}
41+
containerPort: {{ .Values.clickhouse.service.ports.http }}
3942
protocol: TCP
4043
env:
4144
- name: CLICKHOUSE_ADMIN_USER
@@ -52,7 +55,7 @@ spec:
5255
- --host
5356
- localhost
5457
- --port
55-
- "9000"
58+
- {{ .Values.clickhouse.service.ports.native | quote }}
5659
- --user
5760
- {{ .Values.clickhouse.auth.adminUser }}
5861
- --password
@@ -70,7 +73,7 @@ spec:
7073
- --host
7174
- localhost
7275
- --port
73-
- "9000"
76+
- {{ .Values.clickhouse.service.ports.native | quote }}
7477
- --user
7578
- {{ .Values.clickhouse.auth.adminUser }}
7679
- --password
@@ -128,8 +131,12 @@ spec:
128131
type: ClusterIP
129132
clusterIP: None
130133
ports:
134+
- name: native
135+
port: {{ .Values.clickhouse.service.ports.native }}
136+
targetPort: native
137+
protocol: TCP
131138
- name: http
132-
port: {{ .Values.clickhouse.service.port }}
139+
port: {{ .Values.clickhouse.service.ports.http }}
133140
targetPort: http
134141
protocol: TCP
135142
selector:
@@ -145,8 +152,12 @@ metadata:
145152
spec:
146153
type: {{ .Values.clickhouse.service.type }}
147154
ports:
155+
- name: native
156+
port: {{ .Values.clickhouse.service.ports.native }}
157+
targetPort: native
158+
protocol: TCP
148159
- name: http
149-
port: {{ .Values.clickhouse.service.port }}
160+
port: {{ .Values.clickhouse.service.ports.http }}
150161
targetPort: http
151162
protocol: TCP
152163
selector:

hosting/k8s/helm/templates/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.clickhouse.enabled }}
1+
{{- if and .Values.clickhouse.enabled (not .Values.clickhouse.external) }}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.clickhouse.enabled }}
1+
{{- if and .Values.clickhouse.enabled (not .Values.clickhouse.external) }}
22
apiVersion: v1
33
kind: Pod
44
metadata:
@@ -16,6 +16,6 @@ spec:
1616
args:
1717
- |
1818
echo "Testing ClickHouse HTTP interface..."
19-
curl -f "http://{{ .Values.clickhouse.auth.adminUser }}:{{ .Values.clickhouse.auth.adminPassword }}@{{ include "trigger-v4.fullname" . }}-clickhouse:{{ .Values.clickhouse.service.port }}/ping"
19+
curl -f "http://{{ .Values.clickhouse.auth.adminUser }}:{{ .Values.clickhouse.auth.adminPassword }}@{{ include "trigger-v4.fullname" . }}-clickhouse:{{ .Values.clickhouse.service.ports.http }}/ping"
2020
echo "ClickHouse test completed successfully"
2121
{{- end }}

hosting/k8s/helm/templates/webapp.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,20 @@ spec:
187187
value: {{ .Values.webapp.internal.otel.metric.exporterEnabled | quote }}
188188
- name: INTERNAL_OTEL_METRIC_EXPORTER_INTERVAL_MS
189189
value: {{ .Values.webapp.internal.otel.metric.exporterIntervalMs | quote }}
190+
{{- if .Values.webapp.clickhouse.enabled }}
191+
- name: CLICKHOUSE_URL
192+
value: {{ if .Values.clickhouse.external }}{{ .Values.clickhouse.externalConnection.httpUrl | quote }}{{ else }}"http://{{ .Values.clickhouse.auth.adminUser }}:{{ .Values.clickhouse.auth.adminPassword }}@{{ include "trigger-v4.fullname" . }}-clickhouse:{{ .Values.clickhouse.service.ports.http }}"{{ end }}
193+
- name: CLICKHOUSE_LOG_LEVEL
194+
value: {{ .Values.webapp.clickhouse.logLevel | quote }}
195+
{{- end }}
196+
{{- if .Values.webapp.runReplication.enabled }}
197+
- name: RUN_REPLICATION_ENABLED
198+
value: "1"
199+
- name: RUN_REPLICATION_CLICKHOUSE_URL
200+
value: {{ if .Values.clickhouse.external }}{{ .Values.clickhouse.externalConnection.httpUrl | quote }}{{ else }}"http://{{ .Values.clickhouse.auth.adminUser }}:{{ .Values.clickhouse.auth.adminPassword }}@{{ include "trigger-v4.fullname" . }}-clickhouse:{{ .Values.clickhouse.service.ports.http }}"{{ end }}
201+
- name: RUN_REPLICATION_LOG_LEVEL
202+
value: {{ .Values.webapp.runReplication.logLevel | quote }}
203+
{{- end }}
190204
{{- with .Values.webapp.extraEnv }}
191205
{{- toYaml . | nindent 12 }}
192206
{{- end }}

hosting/k8s/helm/values-production-example.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,6 @@ webapp:
4646
requests:
4747
cpu: 1000m
4848
memory: 2Gi
49-
# ClickHouse configuration (experimental)
50-
extraEnv:
51-
[]
52-
# - name: RUN_REPLICATION_CLICKHOUSE_URL
53-
# value: "http://clickhouse:9000"
54-
# - name: RUN_REPLICATION_ENABLED
55-
# value: "1"
56-
# - name: RUN_REPLICATION_LOG_LEVEL
57-
# value: "info"
58-
# - name: CLICKHOUSE_URL
59-
# value: "http://clickhouse:9000"
60-
# - name: CLICKHOUSE_LOG_LEVEL
61-
# value: "info"
6249

6350
# Production PostgreSQL (or use external)
6451
postgres:

hosting/k8s/helm/values.yaml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,6 @@ webapp:
9595
# secretKeyRef:
9696
# name: my-secret
9797
# key: secret-key
98-
# ClickHouse configuration (experimental)
99-
# - name: RUN_REPLICATION_CLICKHOUSE_URL
100-
# value: "http://clickhouse:9000"
101-
# - name: RUN_REPLICATION_ENABLED
102-
# value: "0"
103-
# - name: RUN_REPLICATION_LOG_LEVEL
104-
# value: "info"
105-
# - name: CLICKHOUSE_URL
106-
# value: "http://clickhouse:9000"
107-
# - name: CLICKHOUSE_LOG_LEVEL
108-
# value: "info"
10998

11099
# ServiceMonitor for Prometheus monitoring
111100
serviceMonitor:
@@ -115,6 +104,18 @@ webapp:
115104
labels: {}
116105
basicAuth: {}
117106

107+
# ClickHouse integration (experimental)
108+
# Usage patterns:
109+
# 1. Internal ClickHouse: Set clickhouse.enabled=true, clickhouse.external=false, webapp.clickhouse.enabled=true
110+
# 2. External ClickHouse: Set clickhouse.enabled=true, clickhouse.external=true, configure externalConnection URLs, webapp.clickhouse.enabled=true
111+
# 3. No ClickHouse: Leave webapp.clickhouse.enabled=false (default)
112+
clickhouse:
113+
enabled: true
114+
logLevel: "info" # one of: log, error, warn, info, debug
115+
runReplication:
116+
enabled: true
117+
logLevel: "info" # one of: log, error, warn, info, debug
118+
118119
# OpenTelemetry configuration
119120
internal:
120121
otel:
@@ -152,13 +153,13 @@ secrets:
152153
# If empty, a secret will be created with the values below
153154
# The secret must contain the following keys:
154155
# - session-secret
155-
# - magic-link-secret
156+
# - magic-link-secret
156157
# - encryption-key
157158
# - managed-worker-secret
158159
# - object-store-access-key-id
159160
# - object-store-secret-access-key
160161
existingSecret: ""
161-
162+
162163
# Session secret for user authentication (32 hex chars)
163164
sessionSecret: "2818143646516f6fffd707b36f334bbb"
164165
# Magic link secret for passwordless login (32 hex chars)
@@ -301,6 +302,7 @@ electric:
301302
# ClickHouse configuration
302303
clickhouse:
303304
enabled: true
305+
external: false
304306
image:
305307
registry: docker.io
306308
repository: bitnami/clickhouse
@@ -324,9 +326,14 @@ clickhouse:
324326
size: 10Gi
325327
service:
326328
type: ClusterIP
327-
port: 9000
328-
targetPort: 9000
329+
ports:
330+
native: 9000
331+
http: 8123
329332
resources: {}
333+
# External ClickHouse connection (when external: true)
334+
externalConnection:
335+
# HTTP interface URL (port 8123) - used by webapp for replication
336+
httpUrl: ""
330337
# Extra environment variables for ClickHouse
331338
extraEnv:
332339
[]

0 commit comments

Comments
 (0)