2
0

statefulset.yaml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
  2. kind: StatefulSet
  3. metadata:
  4. name: {{ template "common.names.fullname" . }}
  5. namespace: {{ template "zookeeper.namespace" . }}
  6. labels: {{- include "common.labels.standard" . | nindent 4 }}
  7. test: "{{ .Release.IsUpgrade }}"
  8. version: "{{ .Release.Revision }}"
  9. testinstall: "{{.Release.IsInstall}}"
  10. app.kubernetes.io/component: zookeeper
  11. role: zookeeper
  12. {{- if .Values.commonLabels }}
  13. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  14. {{- end }}
  15. {{- if .Values.commonAnnotations }}
  16. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  17. {{- end }}
  18. spec:
  19. serviceName: {{ template "common.names.fullname" . }}-headless
  20. replicas: {{ .Values.replicaCount }}
  21. podManagementPolicy: {{ .Values.podManagementPolicy }}
  22. updateStrategy:
  23. type: {{ .Values.updateStrategy }}
  24. {{- if (eq "Recreate" .Values.updateStrategy) }}
  25. rollingUpdate: null
  26. {{- else if .Values.rollingUpdatePartition }}
  27. rollingUpdate:
  28. partition: {{ .Values.rollingUpdatePartition }}
  29. {{- end }}
  30. selector:
  31. matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
  32. app.kubernetes.io/component: zookeeper
  33. template:
  34. metadata:
  35. name: {{ template "common.names.fullname" . }}
  36. labels: {{- include "common.labels.standard" . | nindent 8 }}
  37. app.kubernetes.io/component: zookeeper
  38. {{- if .Values.podLabels }}
  39. {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
  40. {{- end }}
  41. {{- if or .Values.podAnnotations (include "zookeeper.client.createTlsSecret" .) (include "zookeeper.quorum.createTlsSecret" .) }}
  42. annotations:
  43. {{- if (include "zookeeper.client.createTlsSecret" .) }}
  44. checksum/tls-client: {{ include (print $.Template.BasePath "/tls-secret.yaml") . | sha256sum }}
  45. {{- end }}
  46. {{- if (include "zookeeper.quorum.createTlsSecret" .) }}
  47. checksum/tls-quorum: {{ include (print $.Template.BasePath "/tls-secret.yaml") . | sha256sum }}
  48. {{- end }}
  49. {{- if .Values.podAnnotations }}
  50. {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
  51. {{- end }}
  52. {{- end }}
  53. spec:
  54. {{- if .Values.schedulerName }}
  55. schedulerName: {{ .Values.schedulerName }}
  56. {{- end }}
  57. {{- include "zookeeper.imagePullSecrets" . | nindent 6 }}
  58. serviceAccountName: {{ template "zookeeper.serviceAccountName" . }}
  59. {{- if .Values.securityContext.enabled }}
  60. securityContext:
  61. fsGroup: {{ .Values.securityContext.fsGroup }}
  62. {{- end }}
  63. {{- if .Values.hostAliases }}
  64. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
  65. {{- end }}
  66. {{- if .Values.affinity }}
  67. affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
  68. {{- else }}
  69. affinity:
  70. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "component" "zookeeper" "context" $) | nindent 10 }}
  71. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "component" "zookeeper" "context" $) | nindent 10 }}
  72. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
  73. {{- end }}
  74. {{- if .Values.nodeSelector }}
  75. nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
  76. {{- end }}
  77. {{- if .Values.tolerations }}
  78. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
  79. {{- end }}
  80. {{- if .Values.priorityClassName }}
  81. priorityClassName: {{ .Values.priorityClassName }}
  82. {{- end }}
  83. {{- if or .Values.initContainers (and .Values.volumePermissions.enabled .Values.persistence.enabled) (or .Values.tls.client.enabled .Values.tls.quorum.enabled) }}
  84. initContainers:
  85. {{- if .Values.initContainers }}
  86. {{ include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | trim | nindent 8 }}
  87. {{- end }}
  88. {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
  89. - name: volume-permissions
  90. image: {{ template "zookeeper.volumePermissions.image" . }}
  91. imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }}
  92. command:
  93. - chown
  94. args:
  95. - -R
  96. - {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}
  97. - /bitnami/zookeeper
  98. {{- if .Values.dataLogDir }}
  99. - {{ .Values.dataLogDir }}
  100. {{- end }}
  101. securityContext:
  102. runAsUser: 0
  103. {{- if .Values.volumePermissions.resources }}
  104. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  105. {{- end }}
  106. volumeMounts:
  107. - name: data
  108. mountPath: /bitnami/zookeeper
  109. {{- if .Values.dataLogDir }}
  110. - name: data-log
  111. mountPath: {{ .Values.dataLogDir }}
  112. {{- end }}
  113. {{- end }}
  114. {{- if or .Values.tls.client.enabled .Values.tls.quorum.enabled }}
  115. - name: init-certs
  116. image: {{ include "zookeeper.image" . }}
  117. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  118. {{- if .Values.securityContext.enabled }}
  119. securityContext:
  120. runAsUser: {{ .Values.securityContext.runAsUser }}
  121. {{- end }}
  122. command:
  123. - /bin/bash
  124. - -ec
  125. - |-
  126. {{- if .Values.tls.client.enabled }}
  127. {{- if .Values.tls.client.autoGenerated }}
  128. if [[ -f "/certs/client/tls.key" ]] && [[ -f "/certs/client/tls.crt" ]] && [[ -f "/certs/client/ca.crt" ]]; then
  129. openssl pkcs12 -export -in "/certs/client/tls.crt" \
  130. -passout pass:"${ZOO_TLS_CLIENT_KEYSTORE_PASSWORD}" \
  131. -inkey "/certs/client/tls.key" \
  132. -out "/tmp/keystore.p12"
  133. keytool -importkeystore -srckeystore "/tmp/keystore.p12" \
  134. -srcstoretype PKCS12 \
  135. -srcstorepass "${ZOO_TLS_CLIENT_KEYSTORE_PASSWORD}" \
  136. -deststorepass "${ZOO_TLS_CLIENT_KEYSTORE_PASSWORD}" \
  137. -destkeystore "/opt/bitnami/zookeeper/config/certs/client/zookeeper.keystore.jks"
  138. rm "/tmp/keystore.p12"
  139. keytool -import -file "/certs/client/ca.crt" \
  140. -keystore "/opt/bitnami/zookeeper/config/certs/client/zookeeper.truststore.jks" \
  141. -storepass "${ZOO_TLS_CLIENT_TRUSTSTORE_PASSWORD}" \
  142. -noprompt
  143. else
  144. echo "Couldn't find the expected PEM certificates! They are mandatory when Client encryption via TLS is enabled."
  145. exit 1
  146. fi
  147. {{- else }}
  148. if [[ -f "/certs/client/zookeeper.truststore.jks" ]] && [[ -f "/certs/client/zookeeper.keystore.jks" ]]; then
  149. cp "/certs/client/zookeeper.truststore.jks" "/opt/bitnami/zookeeper/config/certs/client/zookeeper.truststore.jks"
  150. cp "/certs/client/zookeeper.keystore.jks" "/opt/bitnami/zookeeper/config/certs/client/zookeeper.keystore.jks"
  151. else
  152. echo "Couldn't find the expected Java Key Stores (JKS) files! They are mandatory when Client encryption via TLS is enabled."
  153. exit 1
  154. fi
  155. {{- end }}
  156. {{- end }}
  157. {{- if .Values.tls.quorum.enabled }}
  158. {{- if .Values.tls.quorum.autoGenerated }}
  159. if [[ -f "/certs/quorum/tls.key" ]] && [[ -f "/certs/quorum/tls.crt" ]] && [[ -f "/certs/quorum/ca.crt" ]]; then
  160. openssl pkcs12 -export -in "/certs/quorum/tls.crt" \
  161. -passout pass:"${ZOO_TLS_QUORUM_KEYSTORE_PASSWORD}" \
  162. -inkey "/certs/quorum/tls.key" \
  163. -out "/tmp/keystore.p12"
  164. keytool -importkeystore -srckeystore "/tmp/keystore.p12" \
  165. -srcstoretype PKCS12 \
  166. -srcstorepass "${ZOO_TLS_QUORUM_KEYSTORE_PASSWORD}" \
  167. -deststorepass "${ZOO_TLS_QUORUM_KEYSTORE_PASSWORD}" \
  168. -destkeystore "/opt/bitnami/zookeeper/config/certs/quorum/zookeeper.keystore.jks"
  169. rm "/tmp/keystore.p12"
  170. keytool -import -file "/certs/quorum/ca.crt" \
  171. -keystore "/opt/bitnami/zookeeper/config/certs/quorum/zookeeper.truststore.jks" \
  172. -storepass "${ZOO_TLS_QUORUM_TRUSTSTORE_PASSWORD}" \
  173. -noprompt
  174. else
  175. echo "Couldn't find the expected PEM certificates! They are mandatory when encryption Quorum via TLS is enabled."
  176. exit 1
  177. fi
  178. {{- else }}
  179. if [[ -f "/certs/quorum/zookeeper.truststore.jks" ]] && [[ -f "/certs/quorum/zookeeper.keystore.jks" ]]; then
  180. cp "/certs/quorum/zookeeper.truststore.jks" "/opt/bitnami/zookeeper/config/certs/quorum/zookeeper.truststore.jks"
  181. cp "/certs/quorum/zookeeper.keystore.jks" "/opt/bitnami/zookeeper/config/certs/quorum/zookeeper.keystore.jks"
  182. else
  183. echo "Couldn't find the expected Java Key Stores (JKS) files! They are mandatory when Quorum encryption via TLS is enabled."
  184. exit 1
  185. fi
  186. {{- end }}
  187. {{- end }}
  188. env:
  189. - name: MY_POD_NAME
  190. valueFrom:
  191. fieldRef:
  192. apiVersion: v1
  193. fieldPath: metadata.name
  194. {{- if or .Values.tls.client.keystorePassword .Values.tls.client.passwordsSecretName .Values.tls.client.autoGenerated }}
  195. - name: ZOO_TLS_CLIENT_KEYSTORE_PASSWORD
  196. valueFrom:
  197. secretKeyRef:
  198. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  199. key: "keystore-password"
  200. {{- end }}
  201. {{- if or .Values.tls.client.truststorePassword .Values.tls.client.passwordsSecretName .Values.tls.client.autoGenerated }}
  202. - name: ZOO_TLS_CLIENT_TRUSTSTORE_PASSWORD
  203. valueFrom:
  204. secretKeyRef:
  205. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  206. key: "truststore-password"
  207. {{- end }}
  208. {{- if or .Values.tls.quorum.keystorePassword .Values.tls.quorum.passwordsSecretName .Values.tls.quorum.autoGenerated }}
  209. - name: ZOO_TLS_QUORUM_KEYSTORE_PASSWORD
  210. valueFrom:
  211. secretKeyRef:
  212. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  213. key: "keystore-password"
  214. {{- end }}
  215. {{- if or .Values.tls.quorum.truststorePassword .Values.tls.quorum.passwordsSecretName .Values.tls.quorum.autoGenerated }}
  216. - name: ZOO_TLS_QUORUM_TRUSTSTORE_PASSWORD
  217. valueFrom:
  218. secretKeyRef:
  219. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  220. key: "truststore-password"
  221. {{- end }}
  222. {{- if .Values.tls.resources }}
  223. resources: {{- toYaml .Values.tls.resources | nindent 12 }}
  224. {{- end }}
  225. volumeMounts:
  226. {{- if or .Values.tls.client.enabled }}
  227. - name: client-certificates
  228. mountPath: /certs/client
  229. - name: client-shared-certs
  230. mountPath: /opt/bitnami/zookeeper/config/certs/client
  231. {{- end }}
  232. {{- if or .Values.tls.quorum.enabled }}
  233. - name: quorum-certificates
  234. mountPath: /certs/quorum
  235. - name: quorum-shared-certs
  236. mountPath: /opt/bitnami/zookeeper/config/certs/quorum
  237. {{- end }}
  238. {{- end }}
  239. {{- end }}
  240. containers:
  241. - name: zookeeper
  242. image: {{ template "zookeeper.image" . }}
  243. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  244. {{- if .Values.securityContext.enabled }}
  245. securityContext:
  246. runAsUser: {{ .Values.securityContext.runAsUser }}
  247. {{- end }}
  248. command:
  249. - bash
  250. - -ec
  251. - |
  252. # Execute entrypoint as usual after obtaining ZOO_SERVER_ID
  253. # check ZOO_SERVER_ID in persistent volume via myid
  254. # if not present, set based on POD hostname
  255. if [[ -f "/bitnami/zookeeper/data/myid" ]]; then
  256. export ZOO_SERVER_ID="$(cat /bitnami/zookeeper/data/myid)"
  257. else
  258. HOSTNAME=`hostname -s`
  259. if [[ $HOSTNAME =~ (.*)-([0-9]+)$ ]]; then
  260. ORD=${BASH_REMATCH[2]}
  261. export ZOO_SERVER_ID=$((ORD + {{ .Values.minServerId }} ))
  262. else
  263. echo "Failed to get index from hostname $HOST"
  264. exit 1
  265. fi
  266. fi
  267. exec /entrypoint.sh /run.sh
  268. {{- if .Values.resources }}
  269. resources: {{- toYaml .Values.resources | nindent 12 }}
  270. {{- end }}
  271. env:
  272. - name: ZOO_DATA_LOG_DIR
  273. value: {{ .Values.dataLogDir | quote }}
  274. - name: ZOO_PORT_NUMBER
  275. value: {{ .Values.service.port | quote }}
  276. - name: ZOO_TICK_TIME
  277. value: {{ .Values.tickTime | quote }}
  278. - name: ZOO_INIT_LIMIT
  279. value: {{ .Values.initLimit | quote }}
  280. - name: ZOO_SYNC_LIMIT
  281. value: {{ .Values.syncLimit | quote }}
  282. - name: ZOO_MAX_CLIENT_CNXNS
  283. value: {{ .Values.maxClientCnxns | quote }}
  284. - name: ZOO_4LW_COMMANDS_WHITELIST
  285. value: {{ .Values.fourlwCommandsWhitelist | quote }}
  286. - name: ZOO_LISTEN_ALLIPS_ENABLED
  287. value: {{ ternary "yes" "no" .Values.listenOnAllIPs | quote }}
  288. - name: ZOO_AUTOPURGE_INTERVAL
  289. value: {{ .Values.autopurge.purgeInterval | quote }}
  290. - name: ZOO_AUTOPURGE_RETAIN_COUNT
  291. value: {{ .Values.autopurge.snapRetainCount | quote }}
  292. - name: ZOO_MAX_SESSION_TIMEOUT
  293. value: {{ .Values.maxSessionTimeout | quote }}
  294. - name: ZOO_SERVERS
  295. {{- $replicaCount := int .Values.replicaCount }}
  296. {{- $minServerId := int .Values.minServerId }}
  297. {{- $followerPort := int .Values.service.followerPort }}
  298. {{- $electionPort := int .Values.service.electionPort }}
  299. {{- $releaseNamespace := include "zookeeper.namespace" . }}
  300. {{- $zookeeperFullname := include "common.names.fullname" . }}
  301. {{- $zookeeperHeadlessServiceName := printf "%s-%s" $zookeeperFullname "headless" | trunc 63 }}
  302. {{- $clusterDomain := .Values.clusterDomain }}
  303. value: {{ range $i, $e := until $replicaCount }}{{ $zookeeperFullname }}-{{ $e }}.{{ $zookeeperHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:{{ $followerPort }}:{{ $electionPort }}::{{ add $e $minServerId }} {{ end }}
  304. - name: ZOO_ENABLE_AUTH
  305. value: {{ ternary "yes" "no" .Values.auth.enabled | quote }}
  306. {{- if .Values.auth.enabled }}
  307. - name: ZOO_CLIENT_USER
  308. value: {{ .Values.auth.clientUser | quote }}
  309. - name: ZOO_CLIENT_PASSWORD
  310. valueFrom:
  311. secretKeyRef:
  312. name: {{ if .Values.auth.existingSecret }}{{ .Values.auth.existingSecret }}{{ else }}{{ template "common.names.fullname" . }}{{ end }}
  313. key: client-password
  314. - name: ZOO_SERVER_USERS
  315. value: {{ .Values.auth.serverUsers | quote }}
  316. - name: ZOO_SERVER_PASSWORDS
  317. valueFrom:
  318. secretKeyRef:
  319. name: {{ if .Values.auth.existingSecret }}{{ .Values.auth.existingSecret }}{{ else }}{{ template "common.names.fullname" . }}{{ end }}
  320. key: server-password
  321. {{- end }}
  322. - name: ZOO_HEAP_SIZE
  323. value: {{ .Values.heapSize | quote }}
  324. - name: ZOO_LOG_LEVEL
  325. value: {{ .Values.logLevel | quote }}
  326. - name: ALLOW_ANONYMOUS_LOGIN
  327. value: {{ ternary "yes" "no" .Values.allowAnonymousLogin | quote }}
  328. {{- if .Values.jvmFlags }}
  329. - name: JVMFLAGS
  330. value: {{ .Values.jvmFlags | quote }}
  331. {{- end }}
  332. {{- if .Values.metrics.enabled }}
  333. - name: ZOO_ENABLE_PROMETHEUS_METRICS
  334. value: "yes"
  335. - name: ZOO_PROMETHEUS_METRICS_PORT_NUMBER
  336. value: {{ .Values.metrics.containerPort | quote }}
  337. {{- end }}
  338. {{- if .Values.tls.client.enabled }}
  339. - name: ZOO_TLS_CLIENT_ENABLE
  340. value: {{ .Values.tls.client.enabled | quote }}
  341. - name: ZOO_TLS_CLIENT_KEYSTORE_FILE
  342. value: {{ .Values.tls.client.keystorePath | quote }}
  343. - name: ZOO_TLS_CLIENT_TRUSTSTORE_FILE
  344. value: {{ .Values.tls.client.truststorePath | quote }}
  345. {{- if or .Values.tls.client.keystorePassword .Values.tls.client.passwordsSecretName .Values.tls.client.autoGenerated }}
  346. - name: ZOO_TLS_CLIENT_KEYSTORE_PASSWORD
  347. valueFrom:
  348. secretKeyRef:
  349. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  350. key: "keystore-password"
  351. {{- end }}
  352. {{- if or .Values.tls.client.truststorePassword .Values.tls.client.passwordsSecretName .Values.tls.client.autoGenerated }}
  353. - name: ZOO_TLS_CLIENT_TRUSTSTORE_PASSWORD
  354. valueFrom:
  355. secretKeyRef:
  356. name: {{ include "zookeeper.client.tlsPasswordsSecret" . }}
  357. key: "truststore-password"
  358. {{- end }}
  359. {{- end }}
  360. {{- if .Values.tls.quorum.enabled }}
  361. - name: ZOO_TLS_QUORUM_ENABLE
  362. value: {{ .Values.tls.quorum.enabled | quote }}
  363. - name: ZOO_TLS_QUORUM_KEYSTORE_FILE
  364. value: {{ .Values.tls.quorum.keystorePath | quote }}
  365. - name: ZOO_TLS_QUORUM_TRUSTSTORE_FILE
  366. value: {{ .Values.tls.quorum.truststorePath | quote }}
  367. {{- if or .Values.tls.quorum.keystorePassword .Values.tls.quorum.passwordsSecretName .Values.tls.quorum.autoGenerated }}
  368. - name: ZOO_TLS_QUORUM_KEYSTORE_PASSWORD
  369. valueFrom:
  370. secretKeyRef:
  371. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  372. key: "keystore-password"
  373. {{- end }}
  374. {{- if or .Values.tls.quorum.truststorePassword .Values.tls.quorum.passwordsSecretName .Values.tls.quorum.autoGenerated }}
  375. - name: ZOO_TLS_QUORUM_TRUSTSTORE_PASSWORD
  376. valueFrom:
  377. secretKeyRef:
  378. name: {{ include "zookeeper.quorum.tlsPasswordsSecret" . }}
  379. key: "truststore-password"
  380. {{- end }}
  381. {{- end }}
  382. - name: POD_NAME
  383. valueFrom:
  384. fieldRef:
  385. apiVersion: v1
  386. fieldPath: metadata.name
  387. {{- if .Values.extraEnvVars }}
  388. {{- toYaml .Values.extraEnvVars | nindent 12 }}
  389. {{- end }}
  390. ports:
  391. {{- if not .Values.service.disableBaseClientPort }}
  392. - name: client
  393. containerPort: {{ .Values.service.port }}
  394. {{- end }}
  395. {{- if .Values.tls.client.enabled }}
  396. - name: client-tls
  397. containerPort: {{ .Values.service.tlsClientPort }}
  398. {{- end }}
  399. - name: follower
  400. containerPort: {{ .Values.service.followerPort }}
  401. - name: election
  402. containerPort: {{ .Values.service.electionPort }}
  403. {{- if .Values.metrics.enabled }}
  404. - name: metrics
  405. containerPort: {{ .Values.metrics.containerPort }}
  406. {{- end }}
  407. {{- if .Values.livenessProbe.enabled }}
  408. livenessProbe:
  409. exec:
  410. {{- if not .Values.service.disableBaseClientPort }}
  411. command: ['/bin/bash', '-c', 'echo "ruok" | timeout {{ .Values.livenessProbe.probeCommandTimeout }} nc -w {{ .Values.livenessProbe.probeCommandTimeout }} localhost {{ .Values.service.port }} | grep imok']
  412. {{- else }}
  413. {{- if not .Values.tls.client.enabled }}
  414. command: ['/bin/bash', '-c', 'echo "ruok" | timeout {{ .Values.livenessProbe.probeCommandTimeout }} openssl s_client -quiet -crlf -connect localhost:{{ .Values.service.tlsClientPort }} | grep imok']
  415. {{- else }}
  416. command: ['/bin/bash', '-c', 'echo "ruok" | timeout {{ .Values.livenessProbe.probeCommandTimeout }} openssl s_client -quiet -crlf -connect localhost:{{ .Values.service.tlsClientPort }} -cert {{ .Values.service.tls.client_cert_pem_path }} -key {{ .Values.service.tls.client_key_pem_path }} | grep imok']
  417. {{- end }}
  418. {{- end }}
  419. initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
  420. periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
  421. timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
  422. successThreshold: {{ .Values.livenessProbe.successThreshold }}
  423. failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
  424. {{- else if .Values.customLivenessProbe }}
  425. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
  426. {{- end }}
  427. {{- if .Values.readinessProbe.enabled }}
  428. readinessProbe:
  429. exec:
  430. {{- if not .Values.service.disableBaseClientPort }}
  431. command: ['/bin/bash', '-c', 'echo "ruok" | timeout {{ .Values.readinessProbe.probeCommandTimeout }} nc -w {{ .Values.readinessProbe.probeCommandTimeout }} localhost {{ .Values.service.port }} | grep imok']
  432. {{- else }}
  433. {{- if not .Values.tls.client.enabled }}
  434. command: ['/bin/bash', '-c', 'echo "ruok" | timeout {{ .Values.livenessProbe.probeCommandTimeout }} openssl s_client -quiet -crlf -connect localhost:{{ .Values.service.tlsClientPort }} | grep imok']
  435. {{- else }}
  436. command: ['/bin/bash', '-c', 'echo "ruok" | timeout {{ .Values.livenessProbe.probeCommandTimeout }} openssl s_client -quiet -crlf -connect localhost:{{ .Values.service.tlsClientPort }} -cert {{ .Values.service.tls.client_cert_pem_path }} -key {{ .Values.service.tls.client_key_pem_path }} | grep imok']
  437. {{- end }}
  438. {{- end }}
  439. initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
  440. periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
  441. timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
  442. successThreshold: {{ .Values.readinessProbe.successThreshold }}
  443. failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
  444. {{- else if .Values.customReadinessProbe }}
  445. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
  446. {{- end }}
  447. volumeMounts:
  448. - name: data
  449. mountPath: /bitnami/zookeeper
  450. {{- if .Values.dataLogDir }}
  451. - name: data-log
  452. mountPath: {{ .Values.dataLogDir }}
  453. {{- end }}
  454. {{- if .Values.config }}
  455. - name: config
  456. mountPath: /opt/bitnami/zookeeper/conf/zoo.cfg
  457. subPath: zoo.cfg
  458. {{- end }}
  459. {{- if .Values.tls.client.enabled }}
  460. - name: client-shared-certs
  461. mountPath: /opt/bitnami/zookeeper/config/certs/client
  462. readOnly: true
  463. {{- end }}
  464. {{- if .Values.tls.quorum.enabled }}
  465. - name: quorum-shared-certs
  466. mountPath: /opt/bitnami/zookeeper/config/certs/quorum
  467. readOnly: true
  468. {{- end }}
  469. {{- if .Values.extraVolumeMounts }}
  470. {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
  471. {{- end }}
  472. volumes:
  473. {{- if .Values.config }}
  474. - name: config
  475. configMap:
  476. name: {{ template "common.names.fullname" . }}
  477. {{- end }}
  478. {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
  479. - name: data
  480. persistentVolumeClaim:
  481. claimName: {{ printf "%s" (tpl .Values.persistence.existingClaim .) }}
  482. {{- else if not .Values.persistence.enabled }}
  483. - name: data
  484. emptyDir: {}
  485. {{- end }}
  486. {{- if and .Values.persistence.enabled .Values.persistence.dataLogDir.existingClaim }}
  487. - name: data-log
  488. persistentVolumeClaim:
  489. claimName: {{ printf "%s" (tpl .Values.persistence.dataLogDir.existingClaim .) }}
  490. {{- else if and ( not .Values.persistence.enabled ) .Values.dataLogDir }}
  491. - name: data-log
  492. emptyDir: {}
  493. {{- end }}
  494. {{- if .Values.tls.client.enabled }}
  495. - name: client-certificates
  496. secret:
  497. secretName: {{ include "zookeeper.client.tlsSecretName" . }}
  498. defaultMode: 256
  499. - name: client-shared-certs
  500. emptyDir: {}
  501. {{- end }}
  502. {{- if .Values.tls.quorum.enabled }}
  503. - name: quorum-certificates
  504. secret:
  505. secretName: {{ include "zookeeper.quorum.tlsSecretName" . }}
  506. defaultMode: 256
  507. - name: quorum-shared-certs
  508. emptyDir: {}
  509. {{- end }}
  510. {{- if .Values.extraVolumes }}
  511. {{- toYaml .Values.extraVolumes | nindent 8 }}
  512. {{- end }}
  513. {{- if and .Values.persistence.enabled (not (and .Values.persistence.existingClaim .Values.persistence.dataLogDir.existingClaim) )}}
  514. volumeClaimTemplates:
  515. {{- if not .Values.persistence.existingClaim }}
  516. - metadata:
  517. name: data
  518. annotations:
  519. {{- range $key, $value := .Values.persistence.annotations }}
  520. {{ $key }}: {{ $value }}
  521. {{- end }}
  522. spec:
  523. accessModes:
  524. {{- range .Values.persistence.accessModes }}
  525. - {{ . | quote }}
  526. {{- end }}
  527. resources:
  528. requests:
  529. storage: {{ .Values.persistence.size | quote }}
  530. {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 8 }}
  531. {{- if .Values.persistence.selector }}
  532. selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 10 }}
  533. {{- end }}
  534. {{- end }}
  535. {{- if and (not .Values.persistence.dataLogDir.existingClaim) .Values.dataLogDir }}
  536. - metadata:
  537. name: data-log
  538. annotations:
  539. {{- range $key, $value := .Values.persistence.annotations }}
  540. {{ $key }}: {{ $value }}
  541. {{- end }}
  542. spec:
  543. accessModes:
  544. {{- range .Values.persistence.accessModes }}
  545. - {{ . | quote }}
  546. {{- end }}
  547. resources:
  548. requests:
  549. storage: {{ .Values.persistence.dataLogDir.size | quote }}
  550. {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 8 }}
  551. {{- if .Values.persistence.dataLogDir.selector }}
  552. selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.dataLogDir.selector "context" $) | nindent 10 }}
  553. {{- end }}
  554. {{- end }}
  555. {{- end }}