Skip to content

Commit 8e3746e

Browse files
committed
docs: add ClickHouse cluster documentation
1 parent b3eb9ea commit 8e3746e

File tree

4 files changed

+201
-0
lines changed

4 files changed

+201
-0
lines changed

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,44 @@ populated with random value to ensure uniqueness.
316316

317317
In order for SSL to work without warnings the CA certificate needs to be mounted in the relevant pods. This is not yet implemented as due to an [outstanding issue in tutor](https://github.com/overhangio/tutor/issues/791) that had not yet been completed at the time of writing.
318318

319+
### ClickHouse Cluster
320+
321+
ClickHouse is needed for running Aspects, however for medium/large instances one single ClickHouse node can be
322+
a bottleneck for Aspects and the default ClickHouse deployment in Aspects can take down other services running on the
323+
same node as the ClickHouse pod. In case you are interested on running a ClickHouse cluster, you can enable the
324+
Altinity ClickHouse Operator and follow the templates available on `charts/examples/clickhouse` to setup a ClickHouseKeeper
325+
quorum (needed for replication) and a ClickHouse cluster based on your needs.
326+
327+
Once your cluster is created and working on Kubernetes, you need to update your installation settings:
328+
329+
```yaml
330+
# See the clickhouse-installation.yml template for more details
331+
CLICKHOUSE_ADMIN_USER: default
332+
CLICKHOUSE_ADMIN_PASSWORD: change_me
333+
CLICKHOUSE_CLUSTER_NAME: openedx-demo
334+
# Set the first ClickHouse node as the DDL node.
335+
CLICKHOUSE_CLUSTER_DDL_NODE_HOST: chi-clickhouse-{{CLICKHOUSE_CLUSTER_NAME}}-0-0.{{namespace}}
336+
CLICKHOUSE_HOST: clickhouse-clickhouse.{{namespace}}
337+
CLICKHOUSE_SECURE_CONNECTION: false
338+
RUN_CLICKHOUSE: false
339+
```
340+
341+
For multitenancy you have two options, either have multiple ClickHouse clusters or use different databases and users:
342+
343+
*Using different users and databases*: Make sure to update the users and databases on your config:
344+
345+
```yaml
346+
ASPECTS_CLICKHOUSE_CMS_USER: openedx_demo_ch_cms
347+
ASPECTS_CLICKHOUSE_LRS_USER: openedx_demo_ch_lrs
348+
ASPECTS_CLICKHOUSE_REPORT_USER: openedx_demo_ch_report
349+
ASPECTS_CLICKHOUSE_VECTOR_USER: openedx_demo_ch_vector
350+
ASPECTS_XAPI_DATABASE: openedx_demo_xapi
351+
ASPECTS_EVENT_SINK_DATABASE: openedx_demo_event_sink
352+
ASPECTS_VECTOR_DATABASE: openedx_demo_openedx
353+
DBT_PROFILE_TARGET_DATABASE: openedx_demo_reporting
354+
```
355+
356+
319357
## Extended Documentation
320358

321359
### How to uninstall this chart
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
apiVersion: "clickhouse.altinity.com/v1"
3+
kind: "ClickHouseInstallation"
4+
metadata:
5+
name: "clickhouse"
6+
spec:
7+
configuration:
8+
clusters:
9+
- name: "openedx-demo"
10+
layout:
11+
shardsCount: 1 # Shards have not been tested with Aspects and we don't recommend it.
12+
replicasCount: 2 # Scale as you need/can
13+
templates:
14+
podTemplate: server
15+
volumeClaimTemplate: storage
16+
users:
17+
test/networks/ip:
18+
- "::/0"
19+
test/profile: default
20+
test/password: change_me
21+
test/quota: default
22+
# Default permissions needed for user creation
23+
test/access_management: 1
24+
test/named_collection_control: 1
25+
test/show_named_collections: 1
26+
test/show_named_collections_secrets: 1
27+
zookeeper:
28+
nodes:
29+
- host: clickhouse-keeper-0.clickhouse-keeper-headless
30+
- host: clickhouse-keeper-1.clickhouse-keeper-headless
31+
- host: clickhouse-keeper-2.clickhouse-keeper-headless
32+
files:
33+
# Enable user replication
34+
users-replication.xml: |
35+
<clickhouse>
36+
<user_directories replace="replace">
37+
<users_xml>
38+
<path>/etc/clickhouse-server/users.xml</path>
39+
</users_xml>
40+
<replicated>
41+
<zookeeper_path>/clickhouse/access/</zookeeper_path>
42+
</replicated>
43+
</user_directories>
44+
</clickhouse>
45+
# Enable function replication
46+
functions-replication.xml: |
47+
<clickhouse>
48+
<user_defined_zookeeper_path>/udf</user_defined_zookeeper_path>
49+
</clickhouse>
50+
templates:
51+
podTemplates:
52+
- name: server
53+
spec:
54+
containers:
55+
- name: clickhouse
56+
image: clickhouse/clickhouse-server:24.8
57+
# If you are running a dedicated node group for ClickHouse (and you should)
58+
# make sure to add it tolerations.
59+
tolerations:
60+
- key: "clickhouseInstance"
61+
operator: "Exists"
62+
effect: "NoSchedule"
63+
# Optional: set the nodegroup name
64+
nodeSelector:
65+
eks.amazonaws.com/nodegroup: clickhouse_worker
66+
volumeClaimTemplates:
67+
- name: storage
68+
# Do not delete PV if installation is deleted. If a new ClickHouseInstallation is created
69+
# data will be re-used, allowing recovery of data
70+
reclaimPolicy: Retain
71+
spec:
72+
accessModes:
73+
- ReadWriteOnce
74+
resources:
75+
requests:
76+
storage: 50Gi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apiVersion: "clickhouse-keeper.altinity.com/v1"
2+
kind: "ClickHouseKeeperInstallation"
3+
metadata:
4+
name: clickhouse-keeper
5+
spec:
6+
configuration:
7+
clusters:
8+
- name: "openedx-demo"
9+
layout:
10+
# ClickHouseKeeper needs at least tree pods to form a Quorum for high
11+
# availability.
12+
replicasCount: 3
13+
settings:
14+
logger/level: "trace"
15+
logger/console: "true"
16+
listen_host: "0.0.0.0"
17+
keeper_server/storage_path: /var/lib/clickhouse-keeper
18+
keeper_server/tcp_port: "2181"
19+
keeper_server/four_letter_word_white_list: "*"
20+
keeper_server/coordination_settings/raft_logs_level: "information"
21+
keeper_server/raft_configuration/server/port: "9444"
22+
prometheus/endpoint: "/metrics"
23+
prometheus/port: "7000"
24+
prometheus/metrics: "true"
25+
prometheus/events: "true"
26+
prometheus/asynchronous_metrics: "true"
27+
prometheus/status_info: "false"
28+
templates:
29+
podTemplates:
30+
- name: default
31+
spec:
32+
# affinity removed to allow use in single node test environment
33+
affinity:
34+
podAntiAffinity:
35+
requiredDuringSchedulingIgnoredDuringExecution:
36+
- labelSelector:
37+
matchExpressions:
38+
- key: "app"
39+
operator: In
40+
values:
41+
- clickhouse-keeper
42+
topologyKey: "kubernetes.io/hostname"
43+
containers:
44+
- name: clickhouse-keeper
45+
imagePullPolicy: IfNotPresent
46+
# Make sure to keep this up to date with the ClickHouse compatible version
47+
image: "clickhouse/clickhouse-keeper:24.8-alpine"
48+
resources:
49+
requests:
50+
memory: "256M"
51+
cpu: "0.25"
52+
limits:
53+
memory: "1Gi"
54+
cpu: "1"
55+
priorityClassName: clickhouse-priority
56+
volumeClaimTemplates:
57+
- name: default
58+
spec:
59+
accessModes:
60+
- ReadWriteOnce
61+
resources:
62+
requests:
63+
storage: 10Gi
64+
- name: snapshot-storage-path
65+
spec:
66+
accessModes:
67+
- ReadWriteOnce
68+
resources:
69+
requests:
70+
storage: 10Gi
71+
- name: log-storage-path
72+
spec:
73+
accessModes:
74+
- ReadWriteOnce
75+
resources:
76+
requests:
77+
storage: 10Gi
78+
79+
---
80+
apiVersion: scheduling.k8s.io/v1
81+
kind: PriorityClass
82+
metadata:
83+
name: clickhouse-priority
84+
value: 1000000
85+
globalDefault: false
86+
description: "This priority class should be used for ClickHouse service pods only."

charts/harmony-chart/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,4 @@ clickhouse-operator:
374374
secret:
375375
username: "change_me"
376376
password: "change_me"
377+
fullnameOverride: "clickhouse-operator"

0 commit comments

Comments
 (0)