|
1 |
| -{{/* vim: set filetype=mustache: */}} |
2 | 1 | {{/*
|
3 |
| -Expand the name of the chart. |
| 2 | +Copyright VMware, Inc. |
| 3 | +SPDX-License-Identifier: APACHE-2.0 |
4 | 4 | */}}
|
5 |
| -{{- define "clickhouse.name" -}} |
6 |
| -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} |
| 5 | + |
| 6 | +{{/* |
| 7 | +Return the proper ClickHouse image name |
| 8 | +*/}} |
| 9 | +{{- define "clickhouse.image" -}} |
| 10 | +{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }} |
7 | 11 | {{- end -}}
|
8 | 12 |
|
9 | 13 | {{/*
|
10 |
| -Create a default fully qualified app name. |
11 |
| -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
12 |
| -If release name contains chart name it will be used as a full name. |
| 14 | +Return the proper image name (for the init container volume-permissions image) |
| 15 | +*/}} |
| 16 | +{{- define "clickhouse.volumePermissions.image" -}} |
| 17 | +{{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}} |
| 18 | +{{- end -}} |
| 19 | + |
| 20 | +{{/* |
| 21 | +Return the proper Docker Image Registry Secret Names |
| 22 | +*/}} |
| 23 | +{{- define "clickhouse.imagePullSecrets" -}} |
| 24 | +{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}} |
| 25 | +{{- end -}} |
| 26 | + |
| 27 | +{{/* |
| 28 | +Return true if a TLS credentials secret object should be created |
13 | 29 | */}}
|
14 |
| -{{- define "clickhouse.fullname" -}} |
15 |
| -{{- if .Values.fullnameOverride -}} |
16 |
| -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} |
| 30 | +{{- define "clickhouse.createTlsSecret" -}} |
| 31 | +{{- if and .Values.tls.autoGenerated (not .Values.tls.certificatesSecret) }} |
| 32 | + {{- true -}} |
| 33 | +{{- end -}} |
| 34 | +{{- end -}} |
| 35 | + |
| 36 | +{{/* |
| 37 | +Return the path to the CA cert file. |
| 38 | +*/}} |
| 39 | +{{- define "clickhouse.tlsSecretName" -}} |
| 40 | +{{- if .Values.tls.autoGenerated }} |
| 41 | + {{- printf "%s-crt" (include "common.names.fullname" .) -}} |
17 | 42 | {{- else -}}
|
18 |
| -{{- $name := default .Chart.Name .Values.nameOverride -}} |
19 |
| -{{- if contains $name .Release.Name -}} |
20 |
| -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} |
| 43 | + {{ required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret }} |
| 44 | +{{- end -}} |
| 45 | +{{- end -}} |
| 46 | + |
| 47 | +{{/* |
| 48 | +Return the path to the cert file. |
| 49 | +*/}} |
| 50 | +{{- define "clickhouse.tlsCert" -}} |
| 51 | +{{- if .Values.tls.autoGenerated }} |
| 52 | + {{- printf "/opt/bitnami/clickhouse/certs/tls.crt" -}} |
21 | 53 | {{- else -}}
|
22 |
| -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} |
| 54 | + {{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/bitnami/clickhouse/certs/%s" -}} |
| 55 | +{{- end -}} |
| 56 | +{{- end -}} |
| 57 | + |
| 58 | +{{/* |
| 59 | +Return the path to the cert key file. |
| 60 | +*/}} |
| 61 | +{{- define "clickhouse.tlsCertKey" -}} |
| 62 | +{{- if .Values.tls.autoGenerated }} |
| 63 | + {{- printf "/opt/bitnami/clickhouse/certs/tls.key" -}} |
| 64 | +{{- else -}} |
| 65 | +{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/bitnami/clickhouse/certs/%s" -}} |
| 66 | +{{- end -}} |
| 67 | +{{- end -}} |
| 68 | + |
| 69 | +{{/* |
| 70 | +Return the path to the CA cert file. |
| 71 | +*/}} |
| 72 | +{{- define "clickhouse.tlsCACert" -}} |
| 73 | +{{- if .Values.tls.autoGenerated }} |
| 74 | + {{- printf "/opt/bitnami/clickhouse/certs/ca.crt" -}} |
| 75 | +{{- else -}} |
| 76 | + {{- printf "/opt/bitnami/clickhouse/certs/%s" .Values.tls.certCAFilename -}} |
| 77 | +{{- end -}} |
| 78 | +{{- end -}} |
| 79 | + |
| 80 | +{{/* |
| 81 | +Get the ClickHouse configuration configmap. |
| 82 | +*/}} |
| 83 | +{{- define "clickhouse.configmapName" -}} |
| 84 | +{{- if .Values.existingOverridesConfigmap -}} |
| 85 | + {{- .Values.existingOverridesConfigmap -}} |
| 86 | +{{- else }} |
| 87 | + {{- printf "%s" (include "common.names.fullname" . ) -}} |
| 88 | +{{- end -}} |
| 89 | +{{- end -}} |
| 90 | + |
| 91 | +{{/* |
| 92 | +Get the ClickHouse configuration configmap. |
| 93 | +*/}} |
| 94 | +{{- define "clickhouse.extraConfigmapName" -}} |
| 95 | +{{- if .Values.extraOverridesConfigmap -}} |
| 96 | + {{- .Values.extraOverridesConfigmap -}} |
| 97 | +{{- else }} |
| 98 | + {{- printf "%s-extra" (include "common.names.fullname" . ) -}} |
| 99 | +{{- end -}} |
23 | 100 | {{- end -}}
|
| 101 | + |
| 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 | + |
| 114 | +{{/* |
| 115 | +Get the Clickhouse password secret name |
| 116 | +*/}} |
| 117 | +{{- define "clickhouse.secretName" -}} |
| 118 | +{{- if .Values.auth.existingSecret -}} |
| 119 | + {{- .Values.auth.existingSecret -}} |
| 120 | +{{- else }} |
| 121 | + {{- printf "%s" (include "common.names.fullname" . ) -}} |
24 | 122 | {{- end -}}
|
25 | 123 | {{- end -}}
|
26 | 124 |
|
27 | 125 | {{/*
|
28 |
| -Create chart name and version as used by the chart label. |
| 126 | +Get the ClickHouse password key inside the secret |
29 | 127 | */}}
|
30 |
| -{{- define "clickhouse.chart" -}} |
31 |
| -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} |
| 128 | +{{- define "clickhouse.secretKey" -}} |
| 129 | +{{- if .Values.auth.existingSecret -}} |
| 130 | + {{- .Values.auth.existingSecretKey -}} |
| 131 | +{{- else }} |
| 132 | + {{- print "admin-password" -}} |
| 133 | +{{- end -}} |
32 | 134 | {{- end -}}
|
33 | 135 |
|
34 | 136 | {{/*
|
35 |
| -Create clickhouse path. |
36 |
| -if .Values.clickhouse.path is empty, default value "/var/lib/clickhouse". |
| 137 | +Get the startialization scripts Secret name. |
37 | 138 | */}}
|
38 |
| -{{- define "clickhouse.fullpath" -}} |
39 |
| -{{- if .Values.clickhouse.path -}} |
40 |
| -{{- .Values.clickhouse.path | trunc 63 | trimSuffix "-" -}} |
| 139 | +{{- define "clickhouse.startdbScriptsSecret" -}} |
| 140 | +{{- if .Values.startdbScriptsSecret -}} |
| 141 | + {{- printf "%s" (tpl .Values.startdbScriptsSecret $) -}} |
41 | 142 | {{- else -}}
|
42 |
| -{{- printf "%s" "/var/lib/clickhouse" -}} |
| 143 | + {{- printf "%s-start-scripts" (include "common.names.fullname" .) -}} |
43 | 144 | {{- end -}}
|
44 | 145 | {{- end -}}
|
45 | 146 |
|
46 | 147 | {{/*
|
47 |
| -Create clickhouse log path. |
48 |
| -if .Values.clickhouse.configmap.logger.path is empty, default value "/var/log/clickhouse-server". |
| 148 | +Get the initialization scripts Secret name. |
49 | 149 | */}}
|
50 |
| -{{- define "clickhouse.logpath" -}} |
51 |
| -{{- if .Values.clickhouse.configmap.logger.path -}} |
52 |
| -{{- .Values.clickhouse.configmap.logger.path | trunc 63 | trimSuffix "-" -}} |
| 150 | +{{- define "clickhouse.initdbScriptsSecret" -}} |
| 151 | +{{- if .Values.initdbScriptsSecret -}} |
| 152 | + {{- printf "%s" (tpl .Values.initdbScriptsSecret $) -}} |
53 | 153 | {{- else -}}
|
54 |
| -{{- printf "%s" "/var/log/clickhouse-server" -}} |
| 154 | + {{- printf "%s-init-scripts" (include "common.names.fullname" .) -}} |
| 155 | +{{- end -}} |
| 156 | +{{- end -}} |
| 157 | + |
| 158 | +{{/* |
| 159 | +Return the path to the CA cert file. |
| 160 | +*/}} |
| 161 | +{{- define "clickhouse.headlessServiceName" -}} |
| 162 | +{{- printf "%s-headless" (include "common.names.fullname" .) -}} |
| 163 | +{{- end -}} |
| 164 | + |
| 165 | +{{/* |
| 166 | +Create a default fully qualified app name. |
| 167 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 168 | +*/}} |
| 169 | +{{- define "clickhouse.zookeeper.fullname" -}} |
| 170 | +{{- include "common.names.dependency.fullname" (dict "chartName" "zookeeper" "chartValues" .Values.zookeeper "context" $) -}} |
| 171 | +{{- end -}} |
| 172 | + |
| 173 | +{{/* |
| 174 | +Return the path to the CA cert file. |
| 175 | +*/}} |
| 176 | +{{- define "clickhouse.zookeeper.headlessServiceName" -}} |
| 177 | +{{- printf "%s-headless" (include "clickhouse.zookeeper.fullname" .) -}} |
| 178 | +{{- end -}} |
| 179 | + |
| 180 | +{{/* |
| 181 | +Create the name of the service account to use |
| 182 | +*/}} |
| 183 | +{{- define "clickhouse.serviceAccountName" -}} |
| 184 | +{{- if .Values.serviceAccount.create -}} |
| 185 | + {{ default (include "common.names.fullname" .) .Values.serviceAccount.name }} |
| 186 | +{{- else -}} |
| 187 | + {{ default "default" .Values.serviceAccount.name }} |
| 188 | +{{- end -}} |
| 189 | +{{- end -}} |
| 190 | + |
| 191 | +{{/* |
| 192 | +Compile all warnings into a single message. |
| 193 | +*/}} |
| 194 | +{{- define "clickhouse.validateValues" -}} |
| 195 | +{{- $messages := list -}} |
| 196 | +{{- $messages := append $messages (include "clickhouse.validateValues.zookeeper" .) -}} |
| 197 | +{{- $messages := without $messages "" -}} |
| 198 | +{{- $message := join "\n" $messages -}} |
| 199 | + |
| 200 | +{{- if $message -}} |
| 201 | +{{- printf "\nVALUES VALIDATION:\n%s" $message -}} |
| 202 | +{{- end -}} |
| 203 | +{{- end -}} |
| 204 | + |
| 205 | +{{/* Validate values of ClickHouse - [Zoo]keeper */}} |
| 206 | +{{- define "clickhouse.validateValues.zookeeper" -}} |
| 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 |
| 212 | + using an external instance (--set zookeeper.servers ) |
| 213 | +{{- end -}} |
| 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 |
| 217 | + using an external instance (--set zookeeper.servers ) |
55 | 218 | {{- end -}}
|
56 | 219 | {{- end -}}
|
0 commit comments