|
| 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 -}} |
0 commit comments