Skip to content

Commit 896209a

Browse files
committed
[clickhouse] add clickhouse keeper
Signed-off-by: kklinch0 <[email protected]>
1 parent 2fa56fc commit 896209a

44 files changed

Lines changed: 6713 additions & 3992 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎hack/e2e-apps/clickhouse.bats‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ spec:
2727
s3AccessKey: oobaiRus9pah8PhohL1ThaeTa4UVa7gu
2828
s3SecretKey: ju3eum4dekeich9ahM1te8waeGai0oog
2929
resticPassword: ChaXoveekoh6eigh4siesheeda2quai0
30+
clickhouseKeeper:
31+
enabled: true
32+
resourcesPreset: "micro"
33+
size: "1Gi"
3034
resources: {}
3135
resourcesPreset: "nano"
3236
EOF

‎packages/apps/README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
cd packages/core/installer
55
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
66
make apply
7-
kubectl delete pod dashboard-redis-master-0 -n cozy-dashboard
87
kubectl delete po -l app=source-controller -n cozy-fluxcd
98
```

‎packages/apps/clickhouse/Chart.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type: application
1616
# This is the chart version. This version number should be incremented each time you make changes
1717
# to the chart and its templates, including the app version.
1818
# Versions are expected to follow Semantic Versioning (https://semver.org/)
19-
version: 0.11.1
19+
version: 0.12.0
2020

2121
# This is the version number of the application being deployed. This version number should be
2222
# incremented each time you make changes to the application. Versions are not expected to

‎packages/apps/clickhouse/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include ../../../scripts/package.mk
77
generate:
88
readme-generator-for-helm -v values.yaml -s values.schema.json -r README.md
99
yq -i -o json --indent 4 '.properties.resourcesPreset.enum = $(PRESET_ENUM)' values.schema.json
10+
yq -i -o json --indent 4 '.properties.clickhouseKeeper.resourcesPreset.enum = $(PRESET_ENUM)' values.schema.json
1011

1112
image:
1213
docker buildx build images/clickhouse-backup \

‎packages/apps/clickhouse/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ For more details, read [Restic: Effective Backup from Stdin](https://blog.aenix.
5353
| `backup.s3SecretKey` | Secret key for S3, used for authentication | `ju3eum4dekeich9ahM1te8waeGai0oog` |
5454
| `backup.resticPassword` | Password for Restic backup encryption | `ChaXoveekoh6eigh4siesheeda2quai0` |
5555

56+
### clickhouseKeeper parameters
57+
58+
| Name | Description | Value |
59+
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------- |
60+
| `clickhouseKeeper.enabled` | Deploy ClickHouse Keeper for cluster coordination | `true` |
61+
| `clickhouseKeeper.size` | Persistent Volume Claim size, available for application data | `1Gi` |
62+
| `clickhouseKeeper.resourcesPreset` | Default sizing preset used when `resources` is omitted. Allowed values: nano, micro, small, medium, large, xlarge, 2xlarge. | `micro` |
63+
| `clickhouseKeeper.replicas` | Number of keeper replicas | `3` |
64+
5665
## Parameter examples and reference
5766

5867
### resources and resourcesPreset
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
2+
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
3+
4+
{{- if .Values.clickhouseKeeper.enabled }}
5+
apiVersion: "clickhouse-keeper.altinity.com/v1"
6+
kind: "ClickHouseKeeperInstallation"
7+
metadata:
8+
name: "{{ .Release.Name }}-keeper"
9+
annotations:
10+
prometheus.io/port: "7000"
11+
prometheus.io/scrape: "true"
12+
spec:
13+
namespaceDomainPattern: "%s.svc.{{ $clusterDomain }}"
14+
configuration:
15+
clusters:
16+
- name: "cluster1"
17+
layout:
18+
replicasCount: {{ .Values.clickhouseKeeper.replicas }}
19+
settings:
20+
logger/level: "trace"
21+
logger/console: "true"
22+
listen_host: "0.0.0.0"
23+
keeper_server/four_letter_word_white_list: "*"
24+
keeper_server/coordination_settings/raft_logs_level: "information"
25+
prometheus/endpoint: "/metrics"
26+
prometheus/port: "7000"
27+
prometheus/metrics: "true"
28+
prometheus/events: "true"
29+
prometheus/asynchronous_metrics: "true"
30+
prometheus/status_info: "false"
31+
32+
defaults:
33+
templates:
34+
# Templates are specified as default for all clusters
35+
podTemplate: default
36+
dataVolumeClaimTemplate: default
37+
38+
templates:
39+
podTemplates:
40+
- name: default
41+
metadata:
42+
labels:
43+
app: "{{ .Release.Name }}-keeper"
44+
annotations:
45+
prometheus.io/port: "7000"
46+
prometheus.io/scrape: "true"
47+
spec:
48+
affinity:
49+
podAntiAffinity:
50+
requiredDuringSchedulingIgnoredDuringExecution:
51+
- labelSelector:
52+
matchExpressions:
53+
- key: "app"
54+
operator: In
55+
values:
56+
- "{{ .Release.Name }}-keeper"
57+
topologyKey: "kubernetes.io/hostname"
58+
containers:
59+
- name: clickhouse-keeper
60+
imagePullPolicy: IfNotPresent
61+
image: clickhouse/clickhouse-keeper:24.9.2.42
62+
resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.clickhouseKeeper.resourcesPreset .Values.resources $) | nindent 20 }}
63+
securityContext:
64+
fsGroup: 101
65+
66+
volumeClaimTemplates:
67+
- name: default
68+
spec:
69+
accessModes:
70+
- ReadWriteOnce
71+
resources:
72+
requests:
73+
storage: "{{ .Values.clickhouseKeeper.size }}"
74+
---
75+
apiVersion: operator.victoriametrics.com/v1beta1
76+
kind: VMPodScrape
77+
metadata:
78+
name: {{ .Release.Name }}-keeper
79+
namespace: {{ .Release.Namespace }}
80+
spec:
81+
selector:
82+
matchLabels:
83+
app: {{ .Release.Name }}-keeper
84+
namespaceSelector:
85+
matchNames:
86+
- {{ .Release.Namespace }}
87+
podMetricsEndpoints:
88+
- port: metrics
89+
path: /metrics
90+
interval: 30s
91+
scheme: http
92+
relabelConfigs:
93+
- action: replace
94+
sourceLabels: [__meta_kubernetes_pod_node_name]
95+
targetLabel: instance
96+
{{- end }}

‎packages/apps/clickhouse/templates/clickhouse.yaml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ spec:
9191
layout:
9292
shardsCount: {{ .Values.shards }}
9393
replicasCount: {{ .Values.replicas }}
94+
{{- if .Values.clickhouseKeeper.enabled }}
95+
zookeeper:
96+
nodes:
97+
{{- $replicas := int .Values.clickhouseKeeper.replicas }}
98+
{{- $release := .Release.Name }}
99+
{{- $namespace := .Release.Namespace }}
100+
{{- $clusterDomain := .Values.clusterDomain }}
101+
{{- range $i := until $replicas }}
102+
- host: "chk-{{ $release }}-keeper-cluster1-0-{{ $i }}.{{ $namespace }}.svc.{{ $clusterDomain }}"
103+
port: 2181
104+
{{- end }}
105+
{{- end }}
94106
templates:
95107
volumeClaimTemplates:
96108
- name: data-volume-template

‎packages/apps/clickhouse/templates/dashboard-resourcemap.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ rules:
2323
- workloadmonitors
2424
resourceNames:
2525
- {{ .Release.Name }}
26+
{{- if .Values.clickhouseKeeper.enabled }}
27+
- {{ .Release.Name }}-keeper
28+
{{- end }}
2629
verbs: ["get", "list", "watch"]
2730
---
2831
kind: RoleBinding

‎packages/apps/clickhouse/templates/workloadmonitor.yaml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,18 @@ spec:
1111
selector:
1212
app.kubernetes.io/instance: {{ $.Release.Name }}
1313
version: {{ $.Chart.Version }}
14+
{{- if .Values.clickhouseKeeper.enabled }}
15+
---
16+
apiVersion: cozystack.io/v1alpha1
17+
kind: WorkloadMonitor
18+
metadata:
19+
name: {{ $.Release.Name }}-keeper
20+
spec:
21+
replicas: {{ .Values.clickhouseKeeper.replicas }}
22+
minReplicas: 1
23+
kind: clickhouse
24+
type: clickhouse
25+
selector:
26+
app: {{ $.Release.Name }}-keeper
27+
version: {{ $.Chart.Version }}
28+
{{- end }}

‎packages/apps/clickhouse/values.schema.json‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,42 @@
4545
},
4646
"type": "object"
4747
},
48+
"clickhouseKeeper": {
49+
"properties": {
50+
"enabled": {
51+
"default": true,
52+
"description": "Deploy ClickHouse Keeper for cluster coordination ",
53+
"type": "boolean"
54+
},
55+
"replicas": {
56+
"default": 3,
57+
"description": "Number of keeper replicas",
58+
"type": "number"
59+
},
60+
"resourcesPreset": {
61+
"default": "micro",
62+
"description": "Default sizing preset used when `resources` is omitted. Allowed values: nano, micro, small, medium, large, xlarge, 2xlarge.",
63+
"type": "string"
64+
},
65+
"size": {
66+
"default": "1Gi",
67+
"description": "Persistent Volume Claim size, available for application data",
68+
"type": "string"
69+
}
70+
},
71+
"type": "object",
72+
"resourcesPreset": {
73+
"enum": [
74+
"nano",
75+
"micro",
76+
"small",
77+
"medium",
78+
"large",
79+
"xlarge",
80+
"2xlarge"
81+
]
82+
}
83+
},
4884
"logStorageSize": {
4985
"default": "2Gi",
5086
"description": "Size of Persistent Volume for logs",

0 commit comments

Comments
 (0)