Skip to content

Commit 82c5b2e

Browse files
authored
chore(clickhouse): support keeper (#66)
1 parent 92757da commit 82c5b2e

35 files changed

Lines changed: 1149 additions & 269 deletions

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,4 +475,7 @@ Unless required by applicable law or agreed to in writing, software
475475
distributed under the License is distributed on an "AS IS" BASIS,
476476
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
477477
See the License for the specific language governing permissions and
478-
limitations under the License.
478+
limitations under the License.
479+
480+
481+
https://github.com/ClickHouse/ClickHouse/pull/62366/

addons/clickhouse/24/chart/clickhouse/templates/_helpers.tpl

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{{/*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{/*
27
Return the proper ClickHouse image name
38
*/}}
@@ -94,6 +99,18 @@ Get the ClickHouse configuration configmap.
9499
{{- end -}}
95100
{{- end -}}
96101

102+
103+
{{/*
104+
Get the ClickHouse configuration users configmap.
105+
*/}}
106+
{{- define "clickhouse.usersExtraConfigmapName" -}}
107+
{{- if .Values.usersExtraOverridesConfigmap -}}
108+
{{- .Values.usersExtraOverridesConfigmap -}}
109+
{{- else }}
110+
{{- printf "%s-users-extra" (include "common.names.fullname" . ) -}}
111+
{{- end -}}
112+
{{- end -}}
113+
97114
{{/*
98115
Get the Clickhouse password secret name
99116
*/}}
@@ -185,17 +202,18 @@ Compile all warnings into a single message.
185202
{{- end -}}
186203
{{- end -}}
187204

188-
{{/* Validate values of ClickHouse - Zookeeper */}}
205+
{{/* Validate values of ClickHouse - [Zoo]keeper */}}
189206
{{- 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
207+
{{- if or (and .Values.keeper.enabled .Values.zookeeper.enabled) (and .Values.keeper.enabled .Values.externalZookeeper.servers) (and .Values.zookeeper.enabled .Values.externalZookeeper.servers) -}}
208+
clickhouse: Multiple [Zoo]keeper
209+
You can only use one [zoo]keeper
210+
Please choose use ClickHouse keeper or
211+
installing a Zookeeper chart (--set zookeeper.enabled=true) or
194212
using an external instance (--set zookeeper.servers )
195213
{{- 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
214+
{{- if and (not .Values.keeper.enabled) (not .Values.zookeeper.enabled) (not .Values.externalZookeeper.servers) (ne (int .Values.shards) 1) (ne (int .Values.replicaCount) 1) -}}
215+
clickhouse: No [Zoo]keeper
216+
If you are deploying more than one ClickHouse instance, you need to enable [Zoo]keeper. Please choose installing a [Zoo]keeper (--set keeper.enabled=true) or (--set zookeeper.enabled=true) or
199217
using an external instance (--set zookeeper.servers )
200218
{{- end -}}
201219
{{- end -}}

addons/clickhouse/24/chart/clickhouse/templates/configmap-extra.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- if and .Values.extraOverrides (not .Values.extraOverridesConfigmap) }}
27
apiVersion: v1
38
kind: ConfigMap
49
metadata:
510
name: {{ printf "%s-extra" (include "common.names.fullname" .) }}
611
namespace: {{ include "common.names.namespace" . | quote }}
7-
labels: {{- include "common.labels.standard" . | nindent 4 }}
12+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
813
app.kubernetes.io/component: clickhouse
9-
{{- if .Values.commonLabels }}
10-
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11-
{{- end }}
1214
{{- if .Values.commonAnnotations }}
1315
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1416
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{- if and .Values.usersExtraOverrides (not .Values.usersExtraOverridesConfigmap) }}
7+
apiVersion: v1
8+
kind: ConfigMap
9+
metadata:
10+
name: {{ printf "%s-users-extra" (include "common.names.fullname" .) }}
11+
namespace: {{ include "common.names.namespace" . | quote }}
12+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
13+
app.kubernetes.io/component: clickhouse
14+
{{- if .Values.commonAnnotations }}
15+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
16+
{{- end }}
17+
data:
18+
01_users_extra_overrides.xml: |
19+
{{- include "common.tplvalues.render" (dict "value" .Values.usersExtraOverrides "context" $) | nindent 4 }}
20+
{{- end }}

addons/clickhouse/24/chart/clickhouse/templates/configmap.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- if not .Values.existingOverridesConfigmap }}
27
apiVersion: v1
38
kind: ConfigMap
49
metadata:
510
name: {{ template "common.names.fullname" . }}
611
namespace: {{ include "common.names.namespace" . | quote }}
7-
labels: {{- include "common.labels.standard" . | nindent 4 }}
12+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
813
app.kubernetes.io/component: clickhouse
9-
{{- if .Values.commonLabels }}
10-
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11-
{{- end }}
1214
{{- if .Values.commonAnnotations }}
1315
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1416
{{- end }}

addons/clickhouse/24/chart/clickhouse/templates/extra-list.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- range .Values.extraDeploy }}
27
---
38
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- if .Values.ingress.enabled }}
27
{{- if .Values.ingress.secrets }}
38
{{- range .Values.ingress.secrets }}
@@ -6,12 +11,9 @@ kind: Secret
611
metadata:
712
name: {{ .name }}
813
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 }}
14+
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
1315
{{- if $.Values.commonAnnotations }}
14-
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
16+
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
1517
{{- end }}
1618
type: kubernetes.io/tls
1719
data:
@@ -21,24 +23,22 @@ data:
2123
{{- end }}
2224
{{- end }}
2325
{{- if and .Values.ingress.tls .Values.ingress.selfSigned }}
26+
{{- $secretName := printf "%s-tls" .Values.ingress.hostname }}
2427
{{- $ca := genCA "clickhouse-ca" 365 }}
2528
{{- $cert := genSignedCert .Values.ingress.hostname nil (list .Values.ingress.hostname) 365 $ca }}
2629
apiVersion: v1
2730
kind: Secret
2831
metadata:
29-
name: {{ printf "%s-tls" .Values.ingress.hostname }}
32+
name: {{ $secretName }}
3033
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 }}
34+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
3535
{{- if .Values.commonAnnotations }}
3636
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
3737
{{- end }}
3838
type: kubernetes.io/tls
3939
data:
40-
tls.crt: {{ $cert.Cert | b64enc | quote }}
41-
tls.key: {{ $cert.Key | b64enc | quote }}
42-
ca.crt: {{ $ca.Cert | b64enc | quote }}
40+
tls.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.crt" "defaultValue" $cert.Cert "context" $) }}
41+
tls.key: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.key" "defaultValue" $cert.Key "context" $) }}
42+
ca.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "ca.crt" "defaultValue" $ca.Cert "context" $) }}
4343
{{- end }}
4444
{{- end }}

addons/clickhouse/24/chart/clickhouse/templates/ingress.yaml

100755100644
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- if .Values.ingress.enabled }}
27
apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }}
38
kind: Ingress
49
metadata:
510
name: {{ include "common.names.fullname" . }}
611
namespace: {{ .Release.Namespace | quote }}
7-
labels: {{- include "common.labels.standard" . | nindent 4 }}
8-
{{- if .Values.commonLabels }}
9-
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
10-
{{- end }}
11-
annotations:
12-
{{- if .Values.ingress.annotations }}
13-
{{- include "common.tplvalues.render" (dict "value" .Values.ingress.annotations "context" $) | nindent 4 }}
14-
{{- end }}
15-
{{- if .Values.commonAnnotations }}
16-
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
17-
{{- end }}
12+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
13+
{{- if or .Values.ingress.annotations .Values.commonAnnotations }}
14+
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.ingress.annotations .Values.commonAnnotations ) "context" . ) }}
15+
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
16+
{{- end }}
1817
spec:
1918
{{- if and .Values.ingress.ingressClassName (eq "true" (include "common.ingress.supportsIngressClassname" .)) }}
2019
ingressClassName: {{ .Values.ingress.ingressClassName | quote }}

addons/clickhouse/24/chart/clickhouse/templates/init-scripts-secret.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
16
{{- if and .Values.initdbScripts (not .Values.initdbScriptsSecret) }}
27
apiVersion: v1
38
kind: Secret
49
metadata:
510
name: {{ printf "%s-init-scripts" (include "common.names.fullname" .) }}
611
namespace: {{ include "common.names.namespace" . | quote }}
7-
labels: {{- include "common.labels.standard" . | nindent 4 }}
12+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
813
app.kubernetes.io/component: clickhouse
9-
{{- if .Values.commonLabels }}
10-
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11-
{{- end }}
1214
{{- if .Values.commonAnnotations }}
1315
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1416
{{- end }}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{{- /*
2+
Copyright Broadcom, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{- if .Values.networkPolicy.enabled }}
7+
kind: NetworkPolicy
8+
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
9+
metadata:
10+
name: {{ include "common.names.fullname" . }}
11+
namespace: {{ include "common.names.namespace" . | quote }}
12+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
13+
app.kubernetes.io/component: clickhouse
14+
{{- if .Values.commonAnnotations }}
15+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
19+
podSelector:
20+
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
21+
app.kubernetes.io/component: clickhouse
22+
policyTypes:
23+
- Ingress
24+
- Egress
25+
{{- if .Values.networkPolicy.allowExternalEgress }}
26+
egress:
27+
- {}
28+
{{- else }}
29+
egress:
30+
# Allow dns resolution
31+
- ports:
32+
- port: 53
33+
protocol: UDP
34+
- port: 53
35+
protocol: TCP
36+
# Allow outbound connections to other cluster pods
37+
- ports:
38+
- port: {{ .Values.service.ports.http }}
39+
{{- if .Values.tls.enabled }}
40+
- port: {{ .Values.service.ports.https }}
41+
{{- end }}
42+
- port: {{ .Values.service.ports.tcp }}
43+
{{- if .Values.tls.enabled }}
44+
- port: {{ .Values.service.ports.tcpSecure }}
45+
{{- end }}
46+
{{- if .Values.keeper.enabled }}
47+
- port: {{ .Values.service.ports.keeper }}
48+
- port: {{ .Values.service.ports.keeperInter }}
49+
{{- if .Values.tls.enabled }}
50+
- port: {{ .Values.service.ports.keeperSecure }}
51+
{{- end }}
52+
{{- end }}
53+
- port: {{ .Values.service.ports.mysql }}
54+
- port: {{ .Values.service.ports.postgresql }}
55+
- port: {{ .Values.service.ports.interserver }}
56+
{{- if .Values.metrics.enabled }}
57+
- port: {{ .Values.service.ports.metrics }}
58+
{{- end }}
59+
{{- if $.Values.externalAccess.enabled }}
60+
- port: {{ $.Values.externalAccess.service.ports.http }}
61+
{{- if $.Values.tls.enabled }}
62+
- port: {{ $.Values.externalAccess.service.ports.https }}
63+
{{- end }}
64+
{{- if $.Values.metrics.enabled }}
65+
- port: {{ $.Values.externalAccess.service.ports.metrics }}
66+
{{- end }}
67+
- port: {{ $.Values.externalAccess.service.ports.tcp }}
68+
{{- if $.Values.tls.enabled }}
69+
- port: {{ $.Values.externalAccess.service.ports.tcpSecure }}
70+
{{- end }}
71+
{{- if $.Values.keeper.enabled }}
72+
- port: {{ $.Values.externalAccess.service.ports.keeper }}
73+
- port: {{ $.Values.externalAccess.service.ports.keeperInter }}
74+
{{- if $.Values.tls.enabled }}
75+
- port: {{ $.Values.externalAccess.service.ports.keeperSecure }}
76+
{{- end }}
77+
{{- end }}
78+
- port: {{ $.Values.externalAccess.service.ports.mysql }}
79+
- port: {{ $.Values.externalAccess.service.ports.postgresql }}
80+
- port: {{ $.Values.externalAccess.service.ports.interserver }}
81+
{{- end }}
82+
to:
83+
- podSelector:
84+
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
85+
{{- if .Values.networkPolicy.extraEgress }}
86+
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
87+
{{- end }}
88+
{{- end }}
89+
{{- if eq $.Values.service.type "ClusterIP" }}
90+
ingress:
91+
- ports:
92+
- port: {{ $.Values.containerPorts.http }}
93+
- port: {{ $.Values.containerPorts.tcp }}
94+
- port: {{ $.Values.containerPorts.mysql }}
95+
- port: {{ $.Values.containerPorts.postgresql }}
96+
- port: {{ $.Values.containerPorts.interserver }}
97+
{{- if $.Values.tls.enabled }}
98+
- port: {{ $.Values.containerPorts.tcpSecure }}
99+
- port: {{ $.Values.containerPorts.https }}
100+
{{- end }}
101+
{{- if $.Values.keeper.enabled }}
102+
- port: {{ $.Values.containerPorts.keeper }}
103+
- port: {{ $.Values.containerPorts.keeperInter }}
104+
{{- if $.Values.tls.enabled }}
105+
- port : {{ $.Values.containerPorts.keeperSecure }}
106+
{{- end }}
107+
{{- end }}
108+
{{- if $.Values.metrics.enabled }}
109+
- port: {{ $.Values.containerPorts.metrics }}
110+
{{- end }}
111+
112+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
113+
from:
114+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
115+
- namespaceSelector:
116+
matchLabels:
117+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
118+
{{- end }}
119+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
120+
{{- if $namespace }}
121+
- namespaceSelector:
122+
matchLabels:
123+
kubernetes.io/metadata.name: {{ $namespace }}
124+
{{- end }}
125+
{{- end }}
126+
{{- end }}
127+
{{- if .Values.networkPolicy.extraIngress }}
128+
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
129+
{{- end }}
130+
{{- end }}
131+
{{- if eq $.Values.service.type "LoadBalancer" }}
132+
ingress:
133+
- {}
134+
{{- end }}
135+
{{- end }}

0 commit comments

Comments
 (0)