Skip to content

Commit 9bf33fc

Browse files
committed
chore(addons): add clickhouse
1 parent 0055969 commit 9bf33fc

22 files changed

Lines changed: 2715 additions & 0 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
annotations:
2+
category: Database
3+
apiVersion: v2
4+
appVersion: 22.8.6
5+
dependencies:
6+
- name: common
7+
repository: oci://registry.drycc.cc/charts
8+
tags:
9+
- drycc-common
10+
version: ~1.1.2
11+
description: ClickHouse is an open-source column-oriented OLAP database management system. Use it to boost your database performance while providing linear scalability and hardware efficiency.
12+
home: https://clickhouse.com/
13+
icon: https://drycc.com/assets/stacks/clickhouse/img/clickhouse-stack-220x234.png
14+
keywords:
15+
- database
16+
- sharding
17+
maintainers:
18+
- name: Drycc
19+
url: https://github.com/drycc/charts
20+
name: clickhouse
21+
sources:
22+
- https://github.com/drycc/containers/tree/main/drycc/clickhouse
23+
- https://github.com/ClickHouse/ClickHouse
24+
version: 24

addons/clickhouse/24/chart/clickhouse/README.md

Lines changed: 478 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
CHART NAME: {{ .Chart.Name }}
2+
CHART VERSION: {{ .Chart.Version }}
3+
APP VERSION: {{ .Chart.AppVersion }}
4+
5+
** Please be patient while the chart is being deployed **
6+
7+
{{- if .Values.diagnosticMode.enabled }}
8+
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
9+
10+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
11+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
12+
13+
Get the list of pods by executing:
14+
15+
kubectl get pods --namespace {{ include "common.names.namespace" . | quote }} -l app.kubernetes.io/instance={{ .Release.Name }}
16+
17+
Access the pod you want to debug by executing
18+
19+
kubectl exec --namespace {{ include "common.names.namespace" . | quote }} -ti <NAME OF THE POD> -- bash
20+
21+
In order to replicate the container startup scripts execute this command:
22+
23+
/opt/drycc/scripts/clickhouse/entrypoint.sh /opt/drycc/scripts/clickhouse/run.sh
24+
25+
{{- else }}
26+
27+
ClickHouse is available in the following address:
28+
29+
{{- if .Values.externalAccess.enabled }}
30+
31+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
32+
33+
kubectl get svc --namespace {{ template "common.names.namespace" . }} -l "app.kubernetes.io/name={{ template "common.names.fullname" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=clickhouse" -w
34+
35+
{{- else if (eq "LoadBalancer" .Values.service.type) }}
36+
37+
export SERVICE_IP=$(kubectl get svc --namespace {{ template "common.names.namespace" . }} {{ template "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
38+
39+
{{- else if (eq "NodePort" .Values.service.type)}}
40+
41+
export NODE_IP=$(kubectl get nodes --namespace {{ template "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
42+
export NODE_PORT=$(kubectl get --namespace {{ template "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})
43+
44+
{{- else if (eq "ClusterIP" .Values.service.type)}}
45+
46+
kubectl port-forward --namespace {{ template "common.names.namespace" . }} svc/{{ template "common.names.fullname" . }} {{ .Values.service.ports.tcp }}:9000 &
47+
48+
{{- end }}
49+
50+
Credentials:
51+
52+
echo "Username : {{ .Values.auth.username }}"
53+
echo "Password : $(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "clickhouse.secretName" . }} -o jsonpath="{.data.{{ include "clickhouse.secretKey" .}}}" | base64 -d)"
54+
55+
{{- end }}
56+
57+
{{- include "common.warnings.rollingTag" .Values.image }}
58+
{{- include "clickhouse.validateValues" . }}
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
{{/*
2+
Return the proper ClickHouse image name
3+
*/}}
4+
{{- define "clickhouse.image" -}}
5+
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
6+
{{- end -}}
7+
8+
{{/*
9+
Return the proper image name (for the init container volume-permissions image)
10+
*/}}
11+
{{- define "clickhouse.volumePermissions.image" -}}
12+
{{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}}
13+
{{- end -}}
14+
15+
{{/*
16+
Return the proper Docker Image Registry Secret Names
17+
*/}}
18+
{{- define "clickhouse.imagePullSecrets" -}}
19+
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
20+
{{- end -}}
21+
22+
{{/*
23+
Return true if a TLS credentials secret object should be created
24+
*/}}
25+
{{- define "clickhouse.createTlsSecret" -}}
26+
{{- if and .Values.tls.autoGenerated (not .Values.tls.certificatesSecret) }}
27+
{{- true -}}
28+
{{- end -}}
29+
{{- end -}}
30+
31+
{{/*
32+
Return the path to the CA cert file.
33+
*/}}
34+
{{- define "clickhouse.tlsSecretName" -}}
35+
{{- if .Values.tls.autoGenerated }}
36+
{{- printf "%s-crt" (include "common.names.fullname" .) -}}
37+
{{- else -}}
38+
{{ required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret }}
39+
{{- end -}}
40+
{{- end -}}
41+
42+
{{/*
43+
Return the path to the cert file.
44+
*/}}
45+
{{- define "clickhouse.tlsCert" -}}
46+
{{- if .Values.tls.autoGenerated }}
47+
{{- printf "/opt/drycc/clickhouse/certs/tls.crt" -}}
48+
{{- else -}}
49+
{{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/drycc/clickhouse/certs/%s" -}}
50+
{{- end -}}
51+
{{- end -}}
52+
53+
{{/*
54+
Return the path to the cert key file.
55+
*/}}
56+
{{- define "clickhouse.tlsCertKey" -}}
57+
{{- if .Values.tls.autoGenerated }}
58+
{{- printf "/opt/drycc/clickhouse/certs/tls.key" -}}
59+
{{- else -}}
60+
{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/drycc/clickhouse/certs/%s" -}}
61+
{{- end -}}
62+
{{- end -}}
63+
64+
{{/*
65+
Return the path to the CA cert file.
66+
*/}}
67+
{{- define "clickhouse.tlsCACert" -}}
68+
{{- if .Values.tls.autoGenerated }}
69+
{{- printf "/opt/drycc/clickhouse/certs/ca.crt" -}}
70+
{{- else -}}
71+
{{- printf "/opt/drycc/clickhouse/certs/%s" .Values.tls.certCAFilename -}}
72+
{{- end -}}
73+
{{- end -}}
74+
75+
{{/*
76+
Get the ClickHouse configuration configmap.
77+
*/}}
78+
{{- define "clickhouse.configmapName" -}}
79+
{{- if .Values.existingOverridesConfigmap -}}
80+
{{- .Values.existingOverridesConfigmap -}}
81+
{{- else }}
82+
{{- printf "%s" (include "common.names.fullname" . ) -}}
83+
{{- end -}}
84+
{{- end -}}
85+
86+
{{/*
87+
Get the ClickHouse configuration configmap.
88+
*/}}
89+
{{- define "clickhouse.extraConfigmapName" -}}
90+
{{- if .Values.extraOverridesConfigmap -}}
91+
{{- .Values.extraOverridesConfigmap -}}
92+
{{- else }}
93+
{{- printf "%s-extra" (include "common.names.fullname" . ) -}}
94+
{{- end -}}
95+
{{- end -}}
96+
97+
{{/*
98+
Get the Clickhouse password secret name
99+
*/}}
100+
{{- define "clickhouse.secretName" -}}
101+
{{- if .Values.auth.existingSecret -}}
102+
{{- .Values.auth.existingSecret -}}
103+
{{- else }}
104+
{{- printf "%s" (include "common.names.fullname" . ) -}}
105+
{{- end -}}
106+
{{- end -}}
107+
108+
{{/*
109+
Get the ClickHouse password key inside the secret
110+
*/}}
111+
{{- define "clickhouse.secretKey" -}}
112+
{{- if .Values.auth.existingSecret -}}
113+
{{- .Values.auth.existingSecretKey -}}
114+
{{- else }}
115+
{{- print "admin-password" -}}
116+
{{- end -}}
117+
{{- end -}}
118+
119+
{{/*
120+
Get the startialization scripts Secret name.
121+
*/}}
122+
{{- define "clickhouse.startdbScriptsSecret" -}}
123+
{{- if .Values.startdbScriptsSecret -}}
124+
{{- printf "%s" (tpl .Values.startdbScriptsSecret $) -}}
125+
{{- else -}}
126+
{{- printf "%s-start-scripts" (include "common.names.fullname" .) -}}
127+
{{- end -}}
128+
{{- end -}}
129+
130+
{{/*
131+
Get the initialization scripts Secret name.
132+
*/}}
133+
{{- define "clickhouse.initdbScriptsSecret" -}}
134+
{{- if .Values.initdbScriptsSecret -}}
135+
{{- printf "%s" (tpl .Values.initdbScriptsSecret $) -}}
136+
{{- else -}}
137+
{{- printf "%s-init-scripts" (include "common.names.fullname" .) -}}
138+
{{- end -}}
139+
{{- end -}}
140+
141+
{{/*
142+
Return the path to the CA cert file.
143+
*/}}
144+
{{- define "clickhouse.headlessServiceName" -}}
145+
{{- printf "%s-headless" (include "common.names.fullname" .) -}}
146+
{{- end -}}
147+
148+
{{/*
149+
Create a default fully qualified app name.
150+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
151+
*/}}
152+
{{- define "clickhouse.zookeeper.fullname" -}}
153+
{{- include "common.names.dependency.fullname" (dict "chartName" "zookeeper" "chartValues" .Values.zookeeper "context" $) -}}
154+
{{- end -}}
155+
156+
{{/*
157+
Return the path to the CA cert file.
158+
*/}}
159+
{{- define "clickhouse.zookeeper.headlessServiceName" -}}
160+
{{- printf "%s-headless" (include "clickhouse.zookeeper.fullname" .) -}}
161+
{{- end -}}
162+
163+
{{/*
164+
Create the name of the service account to use
165+
*/}}
166+
{{- define "clickhouse.serviceAccountName" -}}
167+
{{- if .Values.serviceAccount.create -}}
168+
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
169+
{{- else -}}
170+
{{ default "default" .Values.serviceAccount.name }}
171+
{{- end -}}
172+
{{- end -}}
173+
174+
{{/*
175+
Compile all warnings into a single message.
176+
*/}}
177+
{{- define "clickhouse.validateValues" -}}
178+
{{- $messages := list -}}
179+
{{- $messages := append $messages (include "clickhouse.validateValues.zookeeper" .) -}}
180+
{{- $messages := without $messages "" -}}
181+
{{- $message := join "\n" $messages -}}
182+
183+
{{- if $message -}}
184+
{{- printf "\nVALUES VALIDATION:\n%s" $message -}}
185+
{{- end -}}
186+
{{- end -}}
187+
188+
{{/* Validate values of ClickHouse - Zookeeper */}}
189+
{{- define "clickhouse.validateValues.zookeeper" -}}
190+
{{- if and .Values.zookeeper.enabled .Values.externalZookeeper.servers -}}
191+
clickhouse: Multiple Zookeeper
192+
You can only use one zookeeper
193+
Please choose installing a Zookeeper chart (--set zookeeper.enabled=true) or
194+
using an external instance (--set zookeeper.servers )
195+
{{- end -}}
196+
{{- if and (not .Values.zookeeper.enabled) (not .Values.externalZookeeper.servers) (ne (int .Values.shards) 1) (ne (int .Values.replicaCount) 1) -}}
197+
clickhouse: No Zookeeper
198+
If you are deploying more than one ClickHouse instance, you need to enable Zookeeper. Please choose installing a Zookeeper chart (--set zookeeper.enabled=true) or
199+
using an external instance (--set zookeeper.servers )
200+
{{- end -}}
201+
{{- end -}}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if and .Values.extraOverrides (not .Values.extraOverridesConfigmap) }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ printf "%s-extra" (include "common.names.fullname" .) }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
app.kubernetes.io/component: clickhouse
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if .Values.commonAnnotations }}
13+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
data:
16+
01_extra_overrides.xml: |
17+
{{- include "common.tplvalues.render" (dict "value" .Values.extraOverrides "context" $) | nindent 4 }}
18+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if not .Values.existingOverridesConfigmap }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
app.kubernetes.io/component: clickhouse
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if .Values.commonAnnotations }}
13+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
data:
16+
00_default_overrides.xml: |
17+
{{- include "common.tplvalues.render" (dict "value" .Values.defaultConfigurationOverrides "context" $) | nindent 4 }}
18+
{{- end }}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{- range .Values.extraDeploy }}
2+
---
3+
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
4+
{{- end }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{{- if .Values.ingress.enabled }}
2+
{{- if .Values.ingress.secrets }}
3+
{{- range .Values.ingress.secrets }}
4+
apiVersion: v1
5+
kind: Secret
6+
metadata:
7+
name: {{ .name }}
8+
namespace: {{ $.Release.Namespace | quote }}
9+
labels: {{- include "common.labels.standard" $ | nindent 4 }}
10+
{{- if $.Values.commonLabels }}
11+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
12+
{{- end }}
13+
{{- if $.Values.commonAnnotations }}
14+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
15+
{{- end }}
16+
type: kubernetes.io/tls
17+
data:
18+
tls.crt: {{ .certificate | b64enc }}
19+
tls.key: {{ .key | b64enc }}
20+
---
21+
{{- end }}
22+
{{- end }}
23+
{{- if and .Values.ingress.tls .Values.ingress.selfSigned }}
24+
{{- $ca := genCA "clickhouse-ca" 365 }}
25+
{{- $cert := genSignedCert .Values.ingress.hostname nil (list .Values.ingress.hostname) 365 $ca }}
26+
apiVersion: v1
27+
kind: Secret
28+
metadata:
29+
name: {{ printf "%s-tls" .Values.ingress.hostname }}
30+
namespace: {{ .Release.Namespace | quote }}
31+
labels: {{- include "common.labels.standard" . | nindent 4 }}
32+
{{- if .Values.commonLabels }}
33+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
34+
{{- end }}
35+
{{- if .Values.commonAnnotations }}
36+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
37+
{{- end }}
38+
type: kubernetes.io/tls
39+
data:
40+
tls.crt: {{ $cert.Cert | b64enc | quote }}
41+
tls.key: {{ $cert.Key | b64enc | quote }}
42+
ca.crt: {{ $ca.Cert | b64enc | quote }}
43+
{{- end }}
44+
{{- end }}

0 commit comments

Comments
 (0)