_helpers.tpl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. {{/* vim: set filetype=mustache: */}}
  2. {{/*
  3. Return the proper Zookeeper image name
  4. */}}
  5. {{- define "zookeeper.image" -}}
  6. {{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
  7. {{- end -}}
  8. {{/*
  9. Return the proper image name (for the init container volume-permissions image)
  10. */}}
  11. {{- define "zookeeper.volumePermissions.image" -}}
  12. {{ include "common.images.image" (dict "imageRoot" .Values.volumePermissions.image "global" .Values.global) }}
  13. {{- end -}}
  14. {{/*
  15. Return the proper Docker Image Registry Secret Names
  16. */}}
  17. {{- define "zookeeper.imagePullSecrets" -}}
  18. {{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
  19. {{- end -}}
  20. {{/*
  21. Check if there are rolling tags in the images
  22. */}}
  23. {{- define "zookeeper.checkRollingTags" -}}
  24. {{- include "common.warnings.rollingTag" .Values.image }}
  25. {{- end -}}
  26. {{/*
  27. Create the name of the service account to use
  28. */}}
  29. {{- define "zookeeper.serviceAccountName" -}}
  30. {{- if .Values.serviceAccount.create -}}
  31. {{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
  32. {{- else -}}
  33. {{ default "default" .Values.serviceAccount.name }}
  34. {{- end -}}
  35. {{- end -}}
  36. {{/*
  37. Return ZooKeeper Client Password
  38. */}}
  39. {{- define "zookeeper.clientPassword" -}}
  40. {{- if .Values.auth.clientPassword -}}
  41. {{- .Values.auth.clientPassword -}}
  42. {{- else -}}
  43. {{- randAlphaNum 10 -}}
  44. {{- end -}}
  45. {{- end -}}
  46. {{/*
  47. Return ZooKeeper Servers Passwords
  48. */}}
  49. {{- define "zookeeper.serverPasswords" -}}
  50. {{- if .Values.auth.serverPasswords -}}
  51. {{- .Values.auth.serverPasswords -}}
  52. {{- else -}}
  53. {{- randAlphaNum 10 -}}
  54. {{- end -}}
  55. {{- end -}}
  56. {{/*
  57. Return ZooKeeper Namespace to use
  58. */}}
  59. {{- define "zookeeper.namespace" -}}
  60. {{- if .Values.namespaceOverride }}
  61. {{- .Values.namespaceOverride -}}
  62. {{- else }}
  63. {{- .Release.Namespace -}}
  64. {{- end }}
  65. {{- end -}}
  66. {{/*
  67. Return the secret containing Zookeeper quorum TLS certificates
  68. */}}
  69. {{- define "zookeeper.quorum.tlsSecretName" -}}
  70. {{- $secretName := .Values.tls.quorum.existingSecret -}}
  71. {{- if $secretName -}}
  72. {{- printf "%s" (tpl $secretName $) -}}
  73. {{- else -}}
  74. {{- printf "%s-quorum-crt" (include "common.names.fullname" .) -}}
  75. {{- end -}}
  76. {{- end -}}
  77. {{/*
  78. Return true if a TLS secret object should be created
  79. */}}
  80. {{- define "zookeeper.quorum.createTlsSecret" -}}
  81. {{- if and .Values.tls.quorum.enabled .Values.tls.quorum.autoGenerated (not .Values.tls.quorum.existingSecret)}}
  82. {{- true -}}
  83. {{- end -}}
  84. {{- end -}}
  85. {{/*
  86. Return the name of the secret containing the Keystore and truststore password
  87. */}}
  88. {{- define "zookeeper.quorum.tlsPasswordsSecret" -}}
  89. {{- $secretName := .Values.tls.quorum.passwordsSecretName -}}
  90. {{- if $secretName -}}
  91. {{- printf "%s" (tpl $secretName $) -}}
  92. {{- else -}}
  93. {{- printf "%s-quorum-tls-pass" (include "common.names.fullname" .) -}}
  94. {{- end -}}
  95. {{- end -}}
  96. {{/*
  97. Return the secret containing Zookeper client TLS certificates
  98. */}}
  99. {{- define "zookeeper.client.tlsSecretName" -}}
  100. {{- $secretName := .Values.tls.client.existingSecret -}}
  101. {{- if $secretName -}}
  102. {{- printf "%s" (tpl $secretName $) -}}
  103. {{- else -}}
  104. {{- printf "%s-client-crt" (include "common.names.fullname" .) -}}
  105. {{- end -}}
  106. {{- end -}}
  107. {{/*
  108. Return true if a TLS secret object should be created
  109. */}}
  110. {{- define "zookeeper.client.createTlsSecret" -}}
  111. {{- if and .Values.tls.client.enabled .Values.tls.client.autoGenerated (not .Values.tls.client.existingSecret) }}
  112. {{- true -}}
  113. {{- end -}}
  114. {{- end -}}
  115. {{/*
  116. Return the name of the secret containing the Keystore and truststore password
  117. */}}
  118. {{- define "zookeeper.client.tlsPasswordsSecret" -}}
  119. {{- $secretName := .Values.tls.client.passwordsSecretName -}}
  120. {{- if $secretName -}}
  121. {{- printf "%s" (tpl $secretName $) -}}
  122. {{- else -}}
  123. {{- printf "%s-client-tls-pass" (include "common.names.fullname" .) -}}
  124. {{- end -}}
  125. {{- end -}}
  126. {{/*
  127. Compile all warnings into a single message.
  128. */}}
  129. {{- define "zookeeper.validateValues" -}}
  130. {{- $messages := list -}}
  131. {{- $messages := append $messages (include "zookeeper.validateValues.client.tls" .) -}}
  132. {{- $messages := append $messages (include "zookeeper.validateValues.quorum.tls" .) -}}
  133. {{- $messages := without $messages "" -}}
  134. {{- $message := join "\n" $messages -}}
  135. {{- if $message -}}
  136. {{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
  137. {{- end -}}
  138. {{- end -}}
  139. {{/* Validate values of Zookeeper - Client TLS enabled */}}
  140. {{- define "zookeeper.validateValues.client.tls" -}}
  141. {{- if and .Values.tls.client.enabled (not .Values.tls.client.autoGenerated) (not .Values.tls.client.existingSecret) }}
  142. zookeeper: tls.client.enabled
  143. In order to enable Client TLS encryption, you also need to provide
  144. an existing secret containing the Keystore and Truststore or
  145. enable auto-generated certificates.
  146. {{- end -}}
  147. {{- end -}}
  148. {{/* Validate values of Zookeeper - Quorum TLS enabled */}}
  149. {{- define "zookeeper.validateValues.quorum.tls" -}}
  150. {{- if and .Values.tls.quorum.enabled (not .Values.tls.quorum.autoGenerated) (not .Values.tls.quorum.existingSecret) }}
  151. zookeeper: tls.quorum.enabled
  152. In order to enable Quorum TLS, you also need to provide
  153. an existing secret containing the Keystore and Truststore or
  154. enable auto-generated certificates.
  155. {{- end -}}
  156. {{- end -}}