_helpers.tpl 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. Return the proper image name (for the init container volume-permissions image)
  9. */}}
  10. {{- define "clickhouse.volumePermissions.image" -}}
  11. {{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}}
  12. {{- end -}}
  13. {{/*
  14. Return the proper Docker Image Registry Secret Names
  15. */}}
  16. {{- define "clickhouse.imagePullSecrets" -}}
  17. {{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
  18. {{- end -}}
  19. {{/*
  20. Return true if a TLS credentials secret object should be created
  21. */}}
  22. {{- define "clickhouse.createTlsSecret" -}}
  23. {{- if and .Values.tls.autoGenerated (not .Values.tls.certificatesSecret) }}
  24. {{- true -}}
  25. {{- end -}}
  26. {{- end -}}
  27. {{/*
  28. Return the path to the CA cert file.
  29. */}}
  30. {{- define "clickhouse.tlsSecretName" -}}
  31. {{- if .Values.tls.autoGenerated }}
  32. {{- printf "%s-crt" (include "common.names.fullname" .) -}}
  33. {{- else -}}
  34. {{ required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret }}
  35. {{- end -}}
  36. {{- end -}}
  37. {{/*
  38. Return the path to the cert file.
  39. */}}
  40. {{- define "clickhouse.tlsCert" -}}
  41. {{- if .Values.tls.autoGenerated }}
  42. {{- printf "/opt/bitnami/clickhouse/certs/tls.crt" -}}
  43. {{- else -}}
  44. {{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/bitnami/clickhouse/certs/%s" -}}
  45. {{- end -}}
  46. {{- end -}}
  47. {{/*
  48. Return the path to the cert key file.
  49. */}}
  50. {{- define "clickhouse.tlsCertKey" -}}
  51. {{- if .Values.tls.autoGenerated }}
  52. {{- printf "/opt/bitnami/clickhouse/certs/tls.key" -}}
  53. {{- else -}}
  54. {{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/bitnami/clickhouse/certs/%s" -}}
  55. {{- end -}}
  56. {{- end -}}
  57. {{/*
  58. Return the path to the CA cert file.
  59. */}}
  60. {{- define "clickhouse.tlsCACert" -}}
  61. {{- if .Values.tls.autoGenerated }}
  62. {{- printf "/opt/bitnami/clickhouse/certs/ca.crt" -}}
  63. {{- else -}}
  64. {{- printf "/opt/bitnami/clickhouse/certs/%s" .Values.tls.certCAFilename -}}
  65. {{- end -}}
  66. {{- end -}}
  67. {{/*
  68. Get the ClickHouse configuration configmap.
  69. */}}
  70. {{- define "clickhouse.configmapName" -}}
  71. {{- if .Values.existingOverridesConfigmap -}}
  72. {{- .Values.existingOverridesConfigmap -}}
  73. {{- else }}
  74. {{- printf "%s" (include "common.names.fullname" . ) -}}
  75. {{- end -}}
  76. {{- end -}}
  77. {{/*
  78. Get the ClickHouse configuration configmap.
  79. */}}
  80. {{- define "clickhouse.extraConfigmapName" -}}
  81. {{- if .Values.extraOverridesConfigmap -}}
  82. {{- .Values.extraOverridesConfigmap -}}
  83. {{- else }}
  84. {{- printf "%s-extra" (include "common.names.fullname" . ) -}}
  85. {{- end -}}
  86. {{- end -}}
  87. {{/*
  88. Get the Clickhouse password secret name
  89. */}}
  90. {{- define "clickhouse.secretName" -}}
  91. {{- if .Values.auth.existingSecret -}}
  92. {{- .Values.auth.existingSecret -}}
  93. {{- else }}
  94. {{- printf "%s" (include "common.names.fullname" . ) -}}
  95. {{- end -}}
  96. {{- end -}}
  97. {{/*
  98. Get the ClickHouse password key inside the secret
  99. */}}
  100. {{- define "clickhouse.secretKey" -}}
  101. {{- if .Values.auth.existingSecret -}}
  102. {{- .Values.auth.existingSecretKey -}}
  103. {{- else }}
  104. {{- print "admin-password" -}}
  105. {{- end -}}
  106. {{- end -}}
  107. {{/*
  108. Get the startialization scripts Secret name.
  109. */}}
  110. {{- define "clickhouse.startdbScriptsSecret" -}}
  111. {{- if .Values.startdbScriptsSecret -}}
  112. {{- printf "%s" (tpl .Values.startdbScriptsSecret $) -}}
  113. {{- else -}}
  114. {{- printf "%s-start-scripts" (include "common.names.fullname" .) -}}
  115. {{- end -}}
  116. {{- end -}}
  117. {{/*
  118. Get the initialization scripts Secret name.
  119. */}}
  120. {{- define "clickhouse.initdbScriptsSecret" -}}
  121. {{- if .Values.initdbScriptsSecret -}}
  122. {{- printf "%s" (tpl .Values.initdbScriptsSecret $) -}}
  123. {{- else -}}
  124. {{- printf "%s-init-scripts" (include "common.names.fullname" .) -}}
  125. {{- end -}}
  126. {{- end -}}
  127. {{/*
  128. Return the path to the CA cert file.
  129. */}}
  130. {{- define "clickhouse.headlessServiceName" -}}
  131. {{- printf "%s-headless" (include "common.names.fullname" .) -}}
  132. {{- end -}}
  133. {{/*
  134. Create a default fully qualified app name.
  135. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  136. */}}
  137. {{- define "clickhouse.zookeeper.fullname" -}}
  138. {{- include "common.names.dependency.fullname" (dict "chartName" "zookeeper" "chartValues" .Values.zookeeper "context" $) -}}
  139. {{- end -}}
  140. {{/*
  141. Return the path to the CA cert file.
  142. */}}
  143. {{- define "clickhouse.zookeeper.headlessServiceName" -}}
  144. {{- printf "%s-headless" (include "clickhouse.zookeeper.fullname" .) -}}
  145. {{- end -}}
  146. {{/*
  147. Create the name of the service account to use
  148. */}}
  149. {{- define "clickhouse.serviceAccountName" -}}
  150. {{- if .Values.serviceAccount.create -}}
  151. {{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
  152. {{- else -}}
  153. {{ default "default" .Values.serviceAccount.name }}
  154. {{- end -}}
  155. {{- end -}}
  156. {{/*
  157. Compile all warnings into a single message.
  158. */}}
  159. {{- define "clickhouse.validateValues" -}}
  160. {{- $messages := list -}}
  161. {{- $messages := append $messages (include "clickhouse.validateValues.zookeeper" .) -}}
  162. {{- $messages := without $messages "" -}}
  163. {{- $message := join "\n" $messages -}}
  164. {{- if $message -}}
  165. {{- printf "\nVALUES VALIDATION:\n%s" $message -}}
  166. {{- end -}}
  167. {{- end -}}
  168. {{/* Validate values of ClickHouse - [Zoo]keeper */}}
  169. {{- define "clickhouse.validateValues.zookeeper" -}}
  170. {{- if or (and .Values.keeper.enabled .Values.zookeeper.enabled) (and .Values.keeper.enabled .Values.externalZookeeper.servers) (and .Values.zookeeper.enabled .Values.externalZookeeper.servers) -}}
  171. clickhouse: Multiple [Zoo]keeper
  172. You can only use one [zoo]keeper
  173. Please choose use ClickHouse keeper or
  174. installing a Zookeeper chart (--set zookeeper.enabled=true) or
  175. using an external instance (--set zookeeper.servers )
  176. {{- end -}}
  177. {{- if and (not .Values.keeper.enabled) (not .Values.zookeeper.enabled) (not .Values.externalZookeeper.servers) (ne (int .Values.shards) 1) (ne (int .Values.replicaCount) 1) -}}
  178. clickhouse: No [Zoo]keeper
  179. 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
  180. using an external instance (--set zookeeper.servers )
  181. {{- end -}}
  182. {{- end -}}