statefulset.yaml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. {{- /*
  2. Copyright Broadcom, Inc. All Rights Reserved.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
  6. kind: StatefulSet
  7. metadata:
  8. name: {{ template "common.names.fullname" . }}
  9. namespace: {{ template "zookeeper.namespace" . }}
  10. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  11. app.kubernetes.io/component: zookeeper
  12. role: zookeeper
  13. {{- if .Values.commonAnnotations }}
  14. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  15. {{- end }}
  16. spec:
  17. replicas: {{ .Values.replicaCount }}
  18. revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
  19. podManagementPolicy: {{ .Values.podManagementPolicy }}
  20. {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
  21. selector:
  22. matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
  23. app.kubernetes.io/component: zookeeper
  24. serviceName: {{ printf "%s-%s" (include "common.names.fullname" .) (default "headless" .Values.service.headless.servicenameOverride) | trunc 63 | trimSuffix "-" }}
  25. {{- if .Values.updateStrategy }}
  26. updateStrategy: {{- toYaml .Values.updateStrategy | nindent 4 }}
  27. {{- end }}
  28. template:
  29. metadata:
  30. annotations:
  31. {{- if .Values.podAnnotations }}
  32. {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
  33. {{- end }}
  34. {{- if (include "zookeeper.createConfigmap" .) }}
  35. checksum/configuration: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
  36. {{- end }}
  37. {{- if or (include "zookeeper.quorum.createSecret" .) (include "zookeeper.client.createSecret" .) (include "zookeeper.client.createTlsPasswordsSecret" .) (include "zookeeper.quorum.createTlsPasswordsSecret" .) }}
  38. checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
  39. {{- end }}
  40. {{- if or (include "zookeeper.client.createTlsSecret" .) (include "zookeeper.quorum.createTlsSecret" .) }}
  41. checksum/tls-secrets: {{ include (print $.Template.BasePath "/tls-secrets.yaml") . | sha256sum }}
  42. {{- end }}
  43. labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
  44. app.kubernetes.io/component: zookeeper
  45. spec:
  46. enableServiceLinks: {{ .Values.enableServiceLinks }}
  47. serviceAccountName: {{ template "zookeeper.serviceAccountName" . }}
  48. {{- include "zookeeper.imagePullSecrets" . | nindent 6 }}
  49. automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
  50. {{- if .Values.hostAliases }}
  51. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
  52. {{- end }}
  53. {{- if .Values.affinity }}
  54. affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
  55. {{- else }}
  56. affinity:
  57. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "component" "zookeeper" "customLabels" $podLabels "context" $) | nindent 10 }}
  58. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "component" "zookeeper" "customLabels" $podLabels "context" $) | nindent 10 }}
  59. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
  60. {{- end }}
  61. {{- if .Values.nodeSelector }}
  62. nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
  63. {{- end }}
  64. {{- if .Values.tolerations }}
  65. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
  66. {{- end }}
  67. {{- if .Values.topologySpreadConstraints }}
  68. topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" .) | nindent 8 }}
  69. {{- end }}
  70. {{- if .Values.priorityClassName }}
  71. priorityClassName: {{ .Values.priorityClassName }}
  72. {{- end }}
  73. {{- if .Values.schedulerName }}
  74. schedulerName: {{ .Values.schedulerName }}
  75. {{- end }}
  76. {{- if .Values.podSecurityContext.enabled }}
  77. securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.podSecurityContext "context" $) | nindent 8 }}
  78. {{- end }}
  79. {{- if .Values.dnsPolicy }}
  80. dnsPolicy: {{ .Values.dnsPolicy }}
  81. {{- end }}
  82. {{- if .Values.dnsConfig }}
  83. dnsConfig: {{- include "common.tplvalues.render" (dict "value" .Values.dnsConfig "context" $) | nindent 8 }}
  84. {{- end }}
  85. initContainers:
  86. {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
  87. - name: volume-permissions
  88. image: {{ template "zookeeper.volumePermissions.image" . }}
  89. imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }}
  90. command:
  91. - /bin/bash
  92. args:
  93. - -ec
  94. - |
  95. mkdir -p /bitnami/zookeeper
  96. chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} /bitnami/zookeeper
  97. find /bitnami/zookeeper -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}
  98. {{- if .Values.dataLogDir }}
  99. mkdir -p {{ .Values.dataLogDir }}
  100. chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} {{ .Values.dataLogDir }}
  101. find {{ .Values.dataLogDir }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}
  102. {{- end }}
  103. {{- if .Values.volumePermissions.containerSecurityContext.enabled }}
  104. securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.volumePermissions.containerSecurityContext "context" $) | nindent 12 }}
  105. {{- end }}
  106. {{- if .Values.volumePermissions.resources }}
  107. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  108. {{- else if ne .Values.volumePermissions.resourcesPreset "none" }}
  109. resources: {{- include "common.resources.preset" (dict "type" .Values.volumePermissions.resourcesPreset) | nindent 12 }}
  110. {{- end }}
  111. volumeMounts:
  112. - name: empty-dir
  113. mountPath: /tmp
  114. subPath: tmp-dir
  115. - name: data
  116. mountPath: /bitnami/zookeeper
  117. {{- if .Values.dataLogDir }}
  118. - name: data-log
  119. mountPath: {{ .Values.dataLogDir }}
  120. {{- end }}
  121. {{- end }}
  122. {{- if or .Values.tls.client.enabled .Values.tls.quorum.enabled }}
  123. - name: init-certs
  124. image: {{ include "zookeeper.image" . }}
  125. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  126. {{- if .Values.containerSecurityContext.enabled }}
  127. securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) | nindent 12 }}
  128. {{- end }}
  129. command:
  130. - /scripts/init-certs.sh
  131. env:
  132. - name: MY_POD_NAME
  133. valueFrom:
  134. fieldRef:
  135. apiVersion: v1
  136. fieldPath: metadata.name
  137. {{- if or .Values.tls.client.passwordsSecretName (include "zookeeper.client.createTlsPasswordsSecret" .) }}
  138. - name: ZOO_TLS_CLIENT_KEYSTORE_PASSWORD
  139. valueFrom:
  140. secretKeyRef:
  141. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  142. key: {{ include "zookeeper.client.tlsPasswordKeystoreKey" . }}
  143. - name: ZOO_TLS_CLIENT_TRUSTSTORE_PASSWORD
  144. valueFrom:
  145. secretKeyRef:
  146. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  147. key: {{ include "zookeeper.client.tlsPasswordTruststoreKey" . }}
  148. {{- end }}
  149. {{- if or .Values.tls.quorum.passwordsSecretName (include "zookeeper.quorum.createTlsPasswordsSecret" .) }}
  150. - name: ZOO_TLS_QUORUM_KEYSTORE_PASSWORD
  151. valueFrom:
  152. secretKeyRef:
  153. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  154. key: {{ include "zookeeper.quorum.tlsPasswordKeystoreKey" . }}
  155. - name: ZOO_TLS_QUORUM_TRUSTSTORE_PASSWORD
  156. valueFrom:
  157. secretKeyRef:
  158. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  159. key: {{ include "zookeeper.quorum.tlsPasswordTruststoreKey" . }}
  160. {{- end }}
  161. {{- if .Values.tls.resources }}
  162. resources: {{- toYaml .Values.tls.resources | nindent 12 }}
  163. {{- else if ne .Values.tls.resourcesPreset "none" }}
  164. resources: {{- include "common.resources.preset" (dict "type" .Values.tls.resourcesPreset) | nindent 12 }}
  165. {{- end }}
  166. volumeMounts:
  167. - name: empty-dir
  168. mountPath: /tmp
  169. subPath: tmp-dir
  170. - name: scripts
  171. mountPath: /scripts/init-certs.sh
  172. subPath: init-certs.sh
  173. {{- if or .Values.tls.client.enabled }}
  174. - name: client-certificates
  175. mountPath: /certs/client
  176. - name: client-shared-certs
  177. mountPath: /opt/bitnami/zookeeper/config/certs/client
  178. {{- end }}
  179. {{- if or .Values.tls.quorum.enabled }}
  180. - name: quorum-certificates
  181. mountPath: /certs/quorum
  182. - name: quorum-shared-certs
  183. mountPath: /opt/bitnami/zookeeper/config/certs/quorum
  184. {{- end }}
  185. {{- end }}
  186. {{- if .Values.initContainers }}
  187. {{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | trim | nindent 8 }}
  188. {{- end }}
  189. containers:
  190. - name: zookeeper
  191. image: {{ template "zookeeper.image" . }}
  192. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  193. {{- if .Values.containerSecurityContext.enabled }}
  194. securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) | nindent 12 }}
  195. {{- end }}
  196. {{- if .Values.diagnosticMode.enabled }}
  197. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  198. {{- else if .Values.command }}
  199. command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
  200. {{- end }}
  201. {{- if .Values.diagnosticMode.enabled }}
  202. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  203. {{- else if .Values.args }}
  204. args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
  205. {{- end }}
  206. {{- if .Values.resources }}
  207. resources: {{- toYaml .Values.resources | nindent 12 }}
  208. {{- else if ne .Values.resourcesPreset "none" }}
  209. resources: {{- include "common.resources.preset" (dict "type" .Values.resourcesPreset) | nindent 12 }}
  210. {{- end }}
  211. env:
  212. - name: BITNAMI_DEBUG
  213. value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
  214. - name: ZOO_DATA_LOG_DIR
  215. value: {{ .Values.dataLogDir | quote }}
  216. - name: ZOO_PORT_NUMBER
  217. value: {{ .Values.containerPorts.client | quote }}
  218. - name: ZOO_TICK_TIME
  219. value: {{ .Values.tickTime | quote }}
  220. - name: ZOO_INIT_LIMIT
  221. value: {{ .Values.initLimit | quote }}
  222. - name: ZOO_SYNC_LIMIT
  223. value: {{ .Values.syncLimit | quote }}
  224. - name: ZOO_PRE_ALLOC_SIZE
  225. value: {{ .Values.preAllocSize | quote }}
  226. - name: ZOO_SNAPCOUNT
  227. value: {{ .Values.snapCount | quote }}
  228. - name: ZOO_MAX_CLIENT_CNXNS
  229. value: {{ .Values.maxClientCnxns | quote }}
  230. - name: ZOO_4LW_COMMANDS_WHITELIST
  231. value: {{ .Values.fourlwCommandsWhitelist | quote }}
  232. - name: ZOO_LISTEN_ALLIPS_ENABLED
  233. value: {{ ternary "yes" "no" .Values.listenOnAllIPs | quote }}
  234. - name: ZOO_AUTOPURGE_INTERVAL
  235. value: {{ .Values.autopurge.purgeInterval | quote }}
  236. - name: ZOO_AUTOPURGE_RETAIN_COUNT
  237. value: {{ .Values.autopurge.snapRetainCount | quote }}
  238. - name: ZOO_MAX_SESSION_TIMEOUT
  239. value: {{ .Values.maxSessionTimeout | quote }}
  240. - name: ZOO_SERVERS
  241. {{- $replicaCount := int .Values.replicaCount }}
  242. {{- $minServerId := int .Values.minServerId }}
  243. {{- $followerPort := int .Values.containerPorts.follower }}
  244. {{- $electionPort := int .Values.containerPorts.election }}
  245. {{- $releaseNamespace := include "zookeeper.namespace" . }}
  246. {{- $zookeeperFullname := include "common.names.fullname" . }}
  247. {{- $zookeeperHeadlessServiceName := printf "%s-%s" $zookeeperFullname "headless" | trunc 63 }}
  248. {{- $clusterDomain := .Values.clusterDomain }}
  249. value: {{ range $i, $e := until $replicaCount }}{{ $zookeeperFullname }}-{{ $e }}.{{ $zookeeperHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:{{ $followerPort }}:{{ $electionPort }}::{{ add $e $minServerId }} {{ end }}
  250. - name: ZOO_ENABLE_AUTH
  251. value: {{ ternary "yes" "no" .Values.auth.client.enabled | quote }}
  252. {{- if .Values.auth.client.enabled }}
  253. - name: ZOO_CLIENT_USER
  254. value: {{ .Values.auth.client.clientUser | quote }}
  255. - name: ZOO_CLIENT_PASSWORD
  256. valueFrom:
  257. secretKeyRef:
  258. name: {{ include "zookeeper.client.secretName" . }}
  259. key: client-password
  260. - name: ZOO_SERVER_USERS
  261. value: {{ .Values.auth.client.serverUsers | quote }}
  262. - name: ZOO_SERVER_PASSWORDS
  263. valueFrom:
  264. secretKeyRef:
  265. name: {{ include "zookeeper.client.secretName" . }}
  266. key: server-password
  267. {{- end }}
  268. - name: ZOO_ENABLE_QUORUM_AUTH
  269. value: {{ ternary "yes" "no" .Values.auth.quorum.enabled | quote }}
  270. {{- if .Values.auth.quorum.enabled }}
  271. - name: ZOO_QUORUM_LEARNER_USER
  272. value: {{ .Values.auth.quorum.learnerUser | quote }}
  273. - name: ZOO_QUORUM_LEARNER_PASSWORD
  274. valueFrom:
  275. secretKeyRef:
  276. name: {{ include "zookeeper.quorum.secretName" . }}
  277. key: quorum-learner-password
  278. - name: ZOO_QUORUM_SERVER_USERS
  279. value: {{ .Values.auth.quorum.serverUsers | quote }}
  280. - name: ZOO_QUORUM_SERVER_PASSWORDS
  281. valueFrom:
  282. secretKeyRef:
  283. name: {{ include "zookeeper.quorum.secretName" . }}
  284. key: quorum-server-password
  285. {{- end }}
  286. - name: ZOO_HEAP_SIZE
  287. value: {{ .Values.heapSize | quote }}
  288. - name: ZOO_LOG_LEVEL
  289. value: {{ .Values.logLevel | quote }}
  290. - name: ALLOW_ANONYMOUS_LOGIN
  291. value: {{ ternary "no" "yes" .Values.auth.client.enabled | quote }}
  292. {{- if .Values.jvmFlags }}
  293. - name: JVMFLAGS
  294. value: {{ .Values.jvmFlags | quote }}
  295. {{- end }}
  296. {{- if .Values.metrics.enabled }}
  297. - name: ZOO_ENABLE_PROMETHEUS_METRICS
  298. value: "yes"
  299. - name: ZOO_PROMETHEUS_METRICS_PORT_NUMBER
  300. value: {{ coalesce .Values.metrics.containerPort .Values.containerPorts.metrics | quote }}
  301. {{- end }}
  302. {{- if .Values.tls.client.enabled }}
  303. - name: ZOO_TLS_PORT_NUMBER
  304. value: {{ .Values.containerPorts.tls | quote }}
  305. - name: ZOO_TLS_CLIENT_ENABLE
  306. value: {{ .Values.tls.client.enabled | quote }}
  307. - name: ZOO_TLS_CLIENT_AUTH
  308. value: {{ .Values.tls.client.auth | quote }}
  309. - name: ZOO_TLS_CLIENT_KEYSTORE_FILE
  310. value: {{ .Values.tls.client.keystorePath | quote }}
  311. - name: ZOO_TLS_CLIENT_TRUSTSTORE_FILE
  312. value: {{ .Values.tls.client.truststorePath | quote }}
  313. {{- if or .Values.tls.client.keystorePassword .Values.tls.client.passwordsSecretName .Values.tls.client.autoGenerated }}
  314. - name: ZOO_TLS_CLIENT_KEYSTORE_PASSWORD
  315. valueFrom:
  316. secretKeyRef:
  317. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  318. key: {{ include "zookeeper.client.tlsPasswordKeystoreKey" . }}
  319. {{- end }}
  320. {{- if or .Values.tls.client.truststorePassword .Values.tls.client.passwordsSecretName .Values.tls.client.autoGenerated }}
  321. - name: ZOO_TLS_CLIENT_TRUSTSTORE_PASSWORD
  322. valueFrom:
  323. secretKeyRef:
  324. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  325. key: {{ include "zookeeper.client.tlsPasswordTruststoreKey" . }}
  326. {{- end }}
  327. {{- end }}
  328. {{- if .Values.tls.quorum.enabled }}
  329. - name: ZOO_TLS_QUORUM_ENABLE
  330. value: {{ .Values.tls.quorum.enabled | quote }}
  331. - name: ZOO_TLS_QUORUM_CLIENT_AUTH
  332. value: {{ .Values.tls.quorum.auth | quote }}
  333. - name: ZOO_TLS_QUORUM_KEYSTORE_FILE
  334. value: {{ .Values.tls.quorum.keystorePath | quote }}
  335. - name: ZOO_TLS_QUORUM_TRUSTSTORE_FILE
  336. value: {{ .Values.tls.quorum.truststorePath | quote }}
  337. {{- if or .Values.tls.quorum.keystorePassword .Values.tls.quorum.passwordsSecretName .Values.tls.quorum.autoGenerated }}
  338. - name: ZOO_TLS_QUORUM_KEYSTORE_PASSWORD
  339. valueFrom:
  340. secretKeyRef:
  341. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  342. key: {{ include "zookeeper.quorum.tlsPasswordKeystoreKey" . }}
  343. {{- end }}
  344. {{- if or .Values.tls.quorum.truststorePassword .Values.tls.quorum.passwordsSecretName .Values.tls.quorum.autoGenerated }}
  345. - name: ZOO_TLS_QUORUM_TRUSTSTORE_PASSWORD
  346. valueFrom:
  347. secretKeyRef:
  348. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  349. key: {{ include "zookeeper.quorum.tlsPasswordTruststoreKey" . }}
  350. {{- end }}
  351. {{- end }}
  352. - name: POD_NAME
  353. valueFrom:
  354. fieldRef:
  355. apiVersion: v1
  356. fieldPath: metadata.name
  357. - name: ZOO_ADMIN_SERVER_PORT_NUMBER
  358. value: {{ .Values.containerPorts.adminServer | quote }}
  359. {{- if .Values.extraEnvVars }}
  360. {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
  361. {{- end }}
  362. {{- if or .Values.extraEnvVarsCM .Values.extraEnvVarsSecret }}
  363. envFrom:
  364. {{- if .Values.extraEnvVarsCM }}
  365. - configMapRef:
  366. name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }}
  367. {{- end }}
  368. {{- if .Values.extraEnvVarsSecret }}
  369. - secretRef:
  370. name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
  371. {{- end }}
  372. {{- end }}
  373. ports:
  374. {{- if not .Values.service.disableBaseClientPort }}
  375. - name: client
  376. containerPort: {{ .Values.containerPorts.client }}
  377. {{- end }}
  378. {{- if .Values.tls.client.enabled }}
  379. - name: client-tls
  380. containerPort: {{ .Values.containerPorts.tls }}
  381. {{- end }}
  382. {{- if gt (int .Values.replicaCount) 1 }}
  383. {{- /* These ports are only open when there are more than 1 replica */}}
  384. - name: follower
  385. containerPort: {{ .Values.containerPorts.follower }}
  386. - name: election
  387. containerPort: {{ .Values.containerPorts.election }}
  388. {{- end }}
  389. {{- if .Values.metrics.enabled }}
  390. - name: metrics
  391. containerPort: {{ coalesce .Values.metrics.containerPort .Values.containerPorts.metrics }}
  392. {{- end }}
  393. - name: http-admin
  394. containerPort: {{ .Values.containerPorts.adminServer }}
  395. {{- if not .Values.diagnosticMode.enabled }}
  396. {{- if .Values.customLivenessProbe }}
  397. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
  398. {{- else if .Values.livenessProbe.enabled }}
  399. livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled" "probeCommandTimeout") "context" $) | nindent 12 }}
  400. exec:
  401. command:
  402. - /bin/bash
  403. - -ec
  404. - ZOO_HC_TIMEOUT={{ .Values.livenessProbe.probeCommandTimeout }} /opt/bitnami/scripts/zookeeper/healthcheck.sh
  405. {{- end }}
  406. {{- if .Values.customReadinessProbe }}
  407. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
  408. {{- else if .Values.readinessProbe.enabled }}
  409. readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled" "probeCommandTimeout") "context" $) | nindent 12 }}
  410. exec:
  411. command:
  412. - /bin/bash
  413. - -ec
  414. - ZOO_HC_TIMEOUT={{ .Values.readinessProbe.probeCommandTimeout }} /opt/bitnami/scripts/zookeeper/healthcheck.sh
  415. {{- end }}
  416. {{- if .Values.customStartupProbe }}
  417. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }}
  418. {{- else if .Values.startupProbe.enabled }}
  419. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }}
  420. tcpSocket:
  421. {{- if not .Values.service.disableBaseClientPort }}
  422. port: client
  423. {{- else }}
  424. port: follower
  425. {{- end }}
  426. {{- end }}
  427. {{- end }}
  428. {{- if .Values.lifecycleHooks }}
  429. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
  430. {{- end }}
  431. volumeMounts:
  432. - name: empty-dir
  433. mountPath: /tmp
  434. subPath: tmp-dir
  435. - name: empty-dir
  436. mountPath: /opt/bitnami/zookeeper/conf
  437. subPath: app-conf-dir
  438. - name: empty-dir
  439. mountPath: /opt/bitnami/zookeeper/logs
  440. subPath: app-logs-dir
  441. - name: scripts
  442. mountPath: /scripts/setup.sh
  443. subPath: setup.sh
  444. - name: data
  445. mountPath: /bitnami/zookeeper
  446. {{- if .Values.dataLogDir }}
  447. - name: data-log
  448. mountPath: {{ .Values.dataLogDir }}
  449. {{- end }}
  450. {{- if or .Values.configuration .Values.existingConfigmap }}
  451. - name: config
  452. mountPath: /opt/bitnami/zookeeper/conf/zoo.cfg
  453. subPath: zoo.cfg
  454. {{- end }}
  455. {{- if .Values.tls.client.enabled }}
  456. - name: client-shared-certs
  457. mountPath: /opt/bitnami/zookeeper/config/certs/client
  458. readOnly: true
  459. {{- end }}
  460. {{- if .Values.tls.quorum.enabled }}
  461. - name: quorum-shared-certs
  462. mountPath: /opt/bitnami/zookeeper/config/certs/quorum
  463. readOnly: true
  464. {{- end }}
  465. {{- if .Values.extraVolumeMounts }}
  466. {{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumeMounts "context" $ ) | nindent 12 }}
  467. {{- end }}
  468. {{- if .Values.sidecars }}
  469. {{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $ ) | nindent 8 }}
  470. {{- end }}
  471. volumes:
  472. - name: empty-dir
  473. emptyDir: {}
  474. - name: scripts
  475. configMap:
  476. name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
  477. defaultMode: 493
  478. {{- if or .Values.configuration .Values.existingConfigmap }}
  479. - name: config
  480. configMap:
  481. name: {{ include "zookeeper.configmapName" . }}
  482. {{- end }}
  483. {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
  484. - name: data
  485. persistentVolumeClaim:
  486. claimName: {{ printf "%s" (tpl .Values.persistence.existingClaim .) }}
  487. {{- else if not .Values.persistence.enabled }}
  488. - name: data
  489. emptyDir: {}
  490. {{- end }}
  491. {{- if and .Values.persistence.enabled .Values.persistence.dataLogDir.existingClaim }}
  492. - name: data-log
  493. persistentVolumeClaim:
  494. claimName: {{ printf "%s" (tpl .Values.persistence.dataLogDir.existingClaim .) }}
  495. {{- else if and ( not .Values.persistence.enabled ) .Values.dataLogDir }}
  496. - name: data-log
  497. emptyDir: {}
  498. {{- end }}
  499. {{- if .Values.tls.client.enabled }}
  500. - name: client-certificates
  501. secret:
  502. secretName: {{ include "zookeeper.client.tlsSecretName" . }}
  503. defaultMode: 256
  504. - name: client-shared-certs
  505. emptyDir: {}
  506. {{- end }}
  507. {{- if .Values.tls.quorum.enabled }}
  508. - name: quorum-certificates
  509. secret:
  510. secretName: {{ include "zookeeper.quorum.tlsSecretName" . }}
  511. defaultMode: 256
  512. - name: quorum-shared-certs
  513. emptyDir: {}
  514. {{- end }}
  515. {{- if .Values.extraVolumes }}
  516. {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
  517. {{- end }}
  518. {{- if and .Values.persistence.enabled (not (and .Values.persistence.existingClaim .Values.persistence.dataLogDir.existingClaim) ) }}
  519. volumeClaimTemplates:
  520. {{- if not .Values.persistence.existingClaim }}
  521. - apiVersion: v1
  522. kind: PersistentVolumeClaim
  523. metadata:
  524. name: data
  525. {{- if .Values.persistence.annotations }}
  526. annotations: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }}
  527. {{- end }}
  528. {{- if .Values.persistence.labels }}
  529. labels: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.labels "context" $) | nindent 10 }}
  530. {{- end }}
  531. spec:
  532. accessModes:
  533. {{- range .Values.persistence.accessModes }}
  534. - {{ . | quote }}
  535. {{- end }}
  536. resources:
  537. requests:
  538. storage: {{ .Values.persistence.size | quote }}
  539. {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 8 }}
  540. {{- if .Values.persistence.selector }}
  541. selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 10 }}
  542. {{- end }}
  543. {{- end }}
  544. {{- if and (not .Values.persistence.dataLogDir.existingClaim) .Values.dataLogDir }}
  545. - apiVersion: v1
  546. kind: PersistentVolumeClaim
  547. metadata:
  548. name: data-log
  549. {{- if .Values.persistence.annotations }}
  550. annotations: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }}
  551. {{- end }}
  552. {{- if .Values.persistence.labels }}
  553. labels: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.labels "context" $) | nindent 10 }}
  554. {{- end }}
  555. spec:
  556. accessModes:
  557. {{- range .Values.persistence.accessModes }}
  558. - {{ . | quote }}
  559. {{- end }}
  560. resources:
  561. requests:
  562. storage: {{ .Values.persistence.dataLogDir.size | quote }}
  563. {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 8 }}
  564. {{- if .Values.persistence.dataLogDir.selector }}
  565. selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.dataLogDir.selector "context" $) | nindent 10 }}
  566. {{- end }}
  567. {{- end }}
  568. {{- end }}