statefulset.yaml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. {{- $replicaCount := int .Values.replicaCount }}
  2. {{- $fullname := include "kafka.fullname" . }}
  3. {{- $releaseNamespace := .Release.Namespace }}
  4. {{- $clusterDomain := .Values.clusterDomain }}
  5. {{- $interBrokerPort := .Values.service.internalPort }}
  6. {{- $clientPort := .Values.service.port }}
  7. {{- $interBrokerProtocol := include "kafka.listenerType" (dict "protocol" .Values.auth.interBrokerProtocol) -}}
  8. {{- $clientProtocol := include "kafka.listenerType" (dict "protocol" .Values.auth.clientProtocol) -}}
  9. {{- $loadBalancerIPListLength := len .Values.externalAccess.service.loadBalancerIPs }}
  10. {{- if not (and .Values.externalAccess.enabled (not .Values.externalAccess.autoDiscovery.enabled) (not (eq $replicaCount $loadBalancerIPListLength )) (eq .Values.externalAccess.service.type "LoadBalancer")) }}
  11. apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
  12. kind: StatefulSet
  13. metadata:
  14. name: {{ include "kafka.fullname" . }}
  15. labels: {{- include "common.labels.standard" . | nindent 4 }}
  16. app.kubernetes.io/component: kafka
  17. {{- if .Values.commonLabels }}
  18. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  19. {{- end }}
  20. {{- if .Values.commonAnnotations }}
  21. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  22. {{- end }}
  23. spec:
  24. podManagementPolicy: {{ .Values.podManagementPolicy }}
  25. replicas: {{ .Values.replicaCount }}
  26. selector:
  27. matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
  28. app.kubernetes.io/component: kafka
  29. serviceName: {{ template "kafka.fullname" . }}-headless
  30. updateStrategy:
  31. type: {{ .Values.updateStrategy | quote }}
  32. {{- if (eq "OnDelete" .Values.updateStrategy) }}
  33. rollingUpdate: null
  34. {{- else if .Values.rollingUpdatePartition }}
  35. rollingUpdate:
  36. partition: {{ .Values.rollingUpdatePartition }}
  37. {{- end }}
  38. template:
  39. metadata:
  40. labels: {{- include "common.labels.standard" . | nindent 8 }}
  41. app.kubernetes.io/component: kafka
  42. {{- if .Values.podLabels }}
  43. {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
  44. {{- end }}
  45. {{- if or (include "kafka.createConfigmap" .) (include "kafka.createJaasSecret" .) .Values.externalAccess.enabled (include "kafka.metrics.jmx.createConfigmap" .) .Values.podAnnotations }}
  46. annotations:
  47. {{- if (include "kafka.createConfigmap" .) }}
  48. checksum/configuration: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
  49. {{- end }}
  50. {{- if (include "kafka.createJaasSecret" .) }}
  51. checksum/jaas-secret: {{ include (print $.Template.BasePath "/jaas-secret.yaml") . | sha256sum }}
  52. {{- end }}
  53. {{- if (include "kafka.createTlsSecret" .) }}
  54. checksum/tls-secret: {{ include (print $.Template.BasePath "/tls-secret.yaml") . | sha256sum }}
  55. {{- end }}
  56. {{- if .Values.externalAccess.enabled }}
  57. checksum/scripts: {{ include (print $.Template.BasePath "/scripts-configmap.yaml") . | sha256sum }}
  58. {{- end }}
  59. {{- if (include "kafka.metrics.jmx.createConfigmap" .) }}
  60. checksum/jmx-configuration: {{ include (print $.Template.BasePath "/jmx-configmap.yaml") . | sha256sum }}
  61. {{- end }}
  62. {{- if .Values.podAnnotations }}
  63. {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
  64. {{- end }}
  65. {{- end }}
  66. spec:
  67. {{- include "kafka.imagePullSecrets" . | nindent 6 }}
  68. {{- if .Values.hostAliases }}
  69. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
  70. {{- end }}
  71. {{- if .Values.schedulerName }}
  72. schedulerName: {{ .Values.schedulerName | quote }}
  73. {{- end }}
  74. {{- if .Values.affinity }}
  75. affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
  76. {{- else }}
  77. affinity:
  78. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "context" $) | nindent 10 }}
  79. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "context" $) | nindent 10 }}
  80. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
  81. {{- end }}
  82. {{- if .Values.nodeSelector }}
  83. nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
  84. {{- end }}
  85. {{- if .Values.tolerations }}
  86. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
  87. {{- end }}
  88. {{- if .Values.terminationGracePeriodSeconds }}
  89. terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
  90. {{- end }}
  91. {{- if .Values.priorityClassName }}
  92. priorityClassName: {{ .Values.priorityClassName }}
  93. {{- end }}
  94. {{- if .Values.podSecurityContext.enabled }}
  95. securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
  96. {{- end }}
  97. serviceAccountName: {{ template "kafka.serviceAccountName" . }}
  98. {{- if or (and .Values.volumePermissions.enabled .Values.persistence.enabled) (and .Values.externalAccess.enabled .Values.externalAccess.autoDiscovery.enabled) .Values.initContainers }}
  99. initContainers:
  100. {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
  101. - name: volume-permissions
  102. image: {{ include "kafka.volumePermissions.image" . }}
  103. imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
  104. command:
  105. - /bin/bash
  106. args:
  107. - -ec
  108. - |
  109. chown -R "{{ .Values.podSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}" "{{ .Values.persistence.mountPath }}"
  110. chown -R "{{ .Values.podSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}" "{{ .Values.logPersistence.mountPath }}"
  111. securityContext: {{- .Values.volumePermissions.securityContext | toYaml | nindent 12 }}
  112. {{- if .Values.volumePermissions.resources }}
  113. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  114. {{- end }}
  115. volumeMounts:
  116. - name: data
  117. mountPath: {{ .Values.persistence.mountPath }}
  118. - name: logs
  119. mountPath: {{ .Values.logPersistence.mountPath }}
  120. {{- end }}
  121. {{- if and .Values.externalAccess.enabled .Values.externalAccess.autoDiscovery.enabled }}
  122. - name: auto-discovery
  123. image: {{ include "kafka.externalAccess.autoDiscovery.image" . }}
  124. imagePullPolicy: {{ .Values.externalAccess.autoDiscovery.image.pullPolicy | quote }}
  125. command:
  126. - /scripts/auto-discovery.sh
  127. env:
  128. - name: MY_POD_NAME
  129. valueFrom:
  130. fieldRef:
  131. fieldPath: metadata.name
  132. - name: SHARED_FILE
  133. value: "/shared/info.txt"
  134. {{- if .Values.externalAccess.autoDiscovery.resources }}
  135. resources: {{- toYaml .Values.externalAccess.autoDiscovery.resources | nindent 12 }}
  136. {{- end }}
  137. volumeMounts:
  138. - name: shared
  139. mountPath: /shared
  140. - name: logs
  141. mountPath: {{ .Values.logPersistence.mountPath }}
  142. - name: scripts
  143. mountPath: /scripts/auto-discovery.sh
  144. subPath: auto-discovery.sh
  145. {{- end }}
  146. {{- if .Values.initContainers }}
  147. {{- include "common.tplvalues.render" ( dict "value" .Values.initContainers "context" $ ) | nindent 8 }}
  148. {{- end }}
  149. {{- end }}
  150. containers:
  151. - name: kafka
  152. image: {{ include "kafka.image" . }}
  153. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  154. command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
  155. {{- if .Values.args }}
  156. args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
  157. {{- end }}
  158. env:
  159. - name: BITNAMI_DEBUG
  160. value: {{ ternary "true" "false" .Values.image.debug | quote }}
  161. - name: MY_POD_IP
  162. valueFrom:
  163. fieldRef:
  164. fieldPath: status.podIP
  165. - name: MY_POD_NAME
  166. valueFrom:
  167. fieldRef:
  168. fieldPath: metadata.name
  169. - name: KAFKA_CFG_ZOOKEEPER_CONNECT
  170. {{- if .Values.zookeeper.enabled }}
  171. value: {{ include "kafka.zookeeper.fullname" . | quote }}
  172. {{- else }}
  173. value: {{ include "common.tplvalues.render" (dict "value" (join "," .Values.externalZookeeper.servers) "context" $) }}
  174. {{- end }}
  175. - name: KAFKA_INTER_BROKER_LISTENER_NAME
  176. value: {{ .Values.interBrokerListenerName | quote }}
  177. - name: KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP
  178. {{- if .Values.listenerSecurityProtocolMap }}
  179. value: {{ .Values.listenerSecurityProtocolMap | quote }}
  180. {{- else if .Values.externalAccess.enabled }}
  181. value: "INTERNAL:{{ $interBrokerProtocol }},CLIENT:{{ $clientProtocol }},EXTERNAL:{{ $clientProtocol }}"
  182. {{- else }}
  183. value: "INTERNAL:{{ $interBrokerProtocol }},CLIENT:{{ $clientProtocol }}"
  184. {{- end }}
  185. {{- if or ($clientProtocol | regexFind "SASL") ($interBrokerProtocol | regexFind "SASL") (coalesce .Values.auth.sasl.jaas.zookeeperUser .Values.auth.jaas.zookeeperUser) }}
  186. - name: KAFKA_CFG_SASL_ENABLED_MECHANISMS
  187. value: {{ upper (coalesce .Values.auth.sasl.mechanisms .Values.auth.saslMechanisms) | quote }}
  188. - name: KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL
  189. value: {{ upper (coalesce .Values.auth.sasl.interBrokerMechanism .Values.auth.saslInterBrokerMechanism) | quote }}
  190. {{- end }}
  191. - name: KAFKA_CFG_LISTENERS
  192. {{- if .Values.listeners }}
  193. value: {{ join "," .Values.listeners }}
  194. {{- else if .Values.externalAccess.enabled }}
  195. value: "INTERNAL://:{{ $interBrokerPort }},CLIENT://:9092,EXTERNAL://:9094"
  196. {{- else }}
  197. value: "INTERNAL://:{{ $interBrokerPort }},CLIENT://:9092"
  198. {{- end }}
  199. {{- if .Values.externalAccess.enabled }}
  200. {{- if .Values.externalAccess.autoDiscovery.enabled }}
  201. - name: SHARED_FILE
  202. value: "/shared/info.txt"
  203. {{- end }}
  204. {{- if eq .Values.externalAccess.service.type "NodePort" }}
  205. - name: HOST_IP
  206. valueFrom:
  207. fieldRef:
  208. fieldPath: status.hostIP
  209. {{- end }}
  210. {{- else }}
  211. - name: KAFKA_CFG_ADVERTISED_LISTENERS
  212. {{- if .Values.advertisedListeners }}
  213. value: {{ join "," .Values.advertisedListeners }}
  214. {{- else }}
  215. value: "INTERNAL://$(MY_POD_NAME).{{ $fullname }}-headless.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:{{ $interBrokerPort }},CLIENT://$(MY_POD_NAME).{{ $fullname }}-headless.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:{{ $clientPort }}"
  216. {{- end }}
  217. {{- end }}
  218. - name: ALLOW_PLAINTEXT_LISTENER
  219. value: {{ ternary "yes" "no" .Values.allowPlaintextListener | quote }}
  220. {{- if or (include "kafka.client.saslAuthentication" .) (include "kafka.interBroker.saslAuthentication" .) }}
  221. - name: KAFKA_OPTS
  222. value: "-Djava.security.auth.login.config=/opt/bitnami/kafka/config/kafka_jaas.conf"
  223. {{- if (include "kafka.client.saslAuthentication" .) }}
  224. - name: KAFKA_CLIENT_USERS
  225. value: {{ join "," (coalesce .Values.auth.sasl.jaas.clientUsers .Values.auth.jaas.clientUsers) | quote }}
  226. - name: KAFKA_CLIENT_PASSWORDS
  227. valueFrom:
  228. secretKeyRef:
  229. name: {{ include "kafka.jaasSecretName" . }}
  230. key: client-passwords
  231. {{- end }}
  232. {{- if (include "kafka.interBroker.saslAuthentication" .) }}
  233. - name: KAFKA_INTER_BROKER_USER
  234. value: {{ coalesce .Values.auth.sasl.jaas.interBrokerUser .Values.auth.jaas.interBrokerUser | quote }}
  235. - name: KAFKA_INTER_BROKER_PASSWORD
  236. valueFrom:
  237. secretKeyRef:
  238. name: {{ include "kafka.jaasSecretName" . }}
  239. key: inter-broker-password
  240. {{- end }}
  241. {{- end }}
  242. {{- if and .Values.zookeeper.auth.enabled (coalesce .Values.auth.sasl.jaas.zookeeperUser .Values.auth.jaas.zookeeperUser) }}
  243. - name: KAFKA_ZOOKEEPER_PROTOCOL
  244. value: "SASL"
  245. - name: KAFKA_ZOOKEEPER_USER
  246. value: {{ coalesce .Values.auth.sasl.jaas.zookeeperUser .Values.auth.jaas.zookeeperUser | quote }}
  247. - name: KAFKA_ZOOKEEPER_PASSWORD
  248. valueFrom:
  249. secretKeyRef:
  250. name: {{ include "kafka.jaasSecretName" . }}
  251. key: zookeeper-password
  252. {{- end }}
  253. {{- if (include "kafka.tlsEncryption" .) }}
  254. - name: KAFKA_CFG_TLS_TYPE
  255. value: {{ upper .Values.auth.tls.type | quote }}
  256. - name: KAFKA_CFG_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM
  257. value: {{ default "" (coalesce .Values.auth.tls.endpointIdentificationAlgorithm .Values.auth.tlsEndpointIdentificationAlgorithm) | quote }}
  258. - name: KAFKA_CFG_TLS_CLIENT_AUTH
  259. value: {{ ternary "required" "none" (eq .Values.auth.clientProtocol "mtls") | quote }}
  260. {{- $tlsPassword := coalesce .Values.auth.tls.password .Values.auth.jksPassword }}
  261. - name: KAFKA_CERTIFICATE_PASSWORD
  262. value: {{ default "" $tlsPassword | quote }}
  263. {{- end }}
  264. {{- if .Values.metrics.jmx.enabled }}
  265. - name: JMX_PORT
  266. value: "5555"
  267. {{- end }}
  268. - name: KAFKA_VOLUME_DIR
  269. value: {{ .Values.persistence.mountPath | quote }}
  270. - name: KAFKA_LOG_DIR
  271. value: {{ .Values.logPersistence.mountPath | quote }}
  272. - name: KAFKA_CFG_DELETE_TOPIC_ENABLE
  273. value: {{ .Values.deleteTopicEnable | quote }}
  274. - name: KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE
  275. value: {{ .Values.autoCreateTopicsEnable | quote }}
  276. - name: KAFKA_HEAP_OPTS
  277. value: {{ .Values.heapOpts | quote }}
  278. - name: KAFKA_CFG_LOG_FLUSH_INTERVAL_MESSAGES
  279. value: {{ .Values.logFlushIntervalMessages | replace "_" "" | quote }}
  280. - name: KAFKA_CFG_LOG_FLUSH_INTERVAL_MS
  281. value: {{ .Values.logFlushIntervalMs | quote }}
  282. - name: KAFKA_CFG_LOG_RETENTION_BYTES
  283. value: {{ .Values.logRetentionBytes | replace "_" "" | quote }}
  284. - name: KAFKA_CFG_LOG_RETENTION_CHECK_INTERVALS_MS
  285. value: {{ .Values.logRetentionCheckIntervalMs | quote }}
  286. - name: KAFKA_CFG_LOG_RETENTION_HOURS
  287. value: {{ .Values.logRetentionHours | quote }}
  288. - name: KAFKA_CFG_MESSAGE_MAX_BYTES
  289. value: {{ .Values.maxMessageBytes | replace "_" "" | quote }}
  290. - name: KAFKA_CFG_LOG_SEGMENT_BYTES
  291. value: {{ .Values.logSegmentBytes | replace "_" "" | quote }}
  292. - name: KAFKA_CFG_LOG_DIRS
  293. value: {{ .Values.logsDirs | quote }}
  294. - name: KAFKA_CFG_DEFAULT_REPLICATION_FACTOR
  295. value: {{ .Values.defaultReplicationFactor | quote }}
  296. - name: KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR
  297. value: {{ .Values.offsetsTopicReplicationFactor | quote }}
  298. - name: KAFKA_CFG_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
  299. value: {{ .Values.transactionStateLogReplicationFactor | quote }}
  300. - name: KAFKA_CFG_TRANSACTION_STATE_LOG_MIN_ISR
  301. value: {{ .Values.transactionStateLogMinIsr | quote }}
  302. - name: KAFKA_CFG_NUM_IO_THREADS
  303. value: {{ .Values.numIoThreads | quote }}
  304. - name: KAFKA_CFG_NUM_NETWORK_THREADS
  305. value: {{ .Values.numNetworkThreads | quote }}
  306. - name: KAFKA_CFG_NUM_PARTITIONS
  307. value: {{ .Values.numPartitions | quote }}
  308. - name: KAFKA_CFG_NUM_RECOVERY_THREADS_PER_DATA_DIR
  309. value: {{ .Values.numRecoveryThreadsPerDataDir | quote }}
  310. - name: KAFKA_CFG_SOCKET_RECEIVE_BUFFER_BYTES
  311. value: {{ .Values.socketReceiveBufferBytes | quote }}
  312. - name: KAFKA_CFG_SOCKET_REQUEST_MAX_BYTES
  313. value: {{ .Values.socketRequestMaxBytes | replace "_" "" | quote }}
  314. - name: KAFKA_CFG_SOCKET_SEND_BUFFER_BYTES
  315. value: {{ .Values.socketSendBufferBytes | quote }}
  316. - name: KAFKA_CFG_ZOOKEEPER_CONNECTION_TIMEOUT_MS
  317. value: {{ .Values.zookeeperConnectionTimeoutMs | quote }}
  318. {{- if .Values.extraEnvVars }}
  319. {{ include "common.tplvalues.render" ( dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
  320. {{- end }}
  321. ports:
  322. - name: kafka-client
  323. containerPort: 9092
  324. - name: kafka-internal
  325. containerPort: {{ $interBrokerPort }}
  326. {{- if .Values.externalAccess.enabled }}
  327. - name: kafka-external
  328. containerPort: 9094
  329. {{- end }}
  330. {{- if .Values.livenessProbe.enabled }}
  331. livenessProbe:
  332. tcpSocket:
  333. port: kafka-client
  334. initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
  335. timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
  336. failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
  337. periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
  338. successThreshold: {{ .Values.livenessProbe.successThreshold }}
  339. {{- else if .Values.customLivenessProbe }}
  340. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
  341. {{- end }}
  342. {{- if .Values.readinessProbe.enabled }}
  343. readinessProbe:
  344. tcpSocket:
  345. port: kafka-client
  346. initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
  347. timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
  348. failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
  349. periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
  350. successThreshold: {{ .Values.readinessProbe.successThreshold }}
  351. {{- else if .Values.customReadinessProbe }}
  352. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
  353. {{- end }}
  354. {{- if .Values.resources }}
  355. resources: {{- toYaml .Values.resources | nindent 12 }}
  356. {{- end }}
  357. volumeMounts:
  358. - name: data
  359. mountPath: {{ .Values.persistence.mountPath }}
  360. - name: logs
  361. mountPath: {{ .Values.logPersistence.mountPath }}
  362. {{- if or .Values.config .Values.existingConfigmap }}
  363. - name: kafka-config
  364. mountPath: {{ .Values.persistence.mountPath }}/config/server.properties
  365. subPath: server.properties
  366. {{- end }}
  367. {{- if or .Values.log4j .Values.existingLog4jConfigMap }}
  368. - name: log4j-config
  369. mountPath: {{ .Values.persistence.mountPath }}/config/log4j.properties
  370. subPath: log4j.properties
  371. {{- end }}
  372. - name: scripts
  373. mountPath: /scripts/setup.sh
  374. subPath: setup.sh
  375. {{- if and .Values.externalAccess.enabled .Values.externalAccess.autoDiscovery.enabled }}
  376. - name: shared
  377. mountPath: /shared
  378. {{- end }}
  379. {{- if (include "kafka.tlsEncryption" .) }}
  380. - name: kafka-certificates
  381. mountPath: /certs
  382. readOnly: true
  383. {{- if (coalesce .Values.auth.tls.jksTruststoreSecret .Values.auth.jksTruststoreSecret) }}
  384. - name: kafka-truststore
  385. mountPath: /truststore
  386. readOnly: true
  387. {{- end }}
  388. {{- end }}
  389. {{- if .Values.extraVolumeMounts }}
  390. {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
  391. {{- end }}
  392. {{- if .Values.metrics.jmx.enabled }}
  393. - name: jmx-exporter
  394. image: {{ template "kafka.metrics.jmx.image" . }}
  395. imagePullPolicy: {{ .Values.metrics.jmx.image.pullPolicy | quote }}
  396. command:
  397. - java
  398. - -XX:+UnlockExperimentalVMOptions
  399. - -XX:+UseCGroupMemoryLimitForHeap
  400. - -XX:MaxRAMFraction=1
  401. - -XshowSettings:vm
  402. - -jar
  403. - jmx_prometheus_httpserver.jar
  404. - "5556"
  405. - /etc/jmx-kafka/jmx-kafka-prometheus.yml
  406. ports:
  407. - name: metrics
  408. containerPort: 5556
  409. {{- if .Values.metrics.jmx.resources }}
  410. resources: {{- toYaml .Values.metrics.jmx.resources | nindent 12 }}
  411. {{- end }}
  412. volumeMounts:
  413. - name: jmx-config
  414. mountPath: /etc/jmx-kafka
  415. {{- end }}
  416. {{- if .Values.sidecars }}
  417. {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
  418. {{- end }}
  419. volumes:
  420. {{- if or .Values.config .Values.existingConfigmap }}
  421. - name: kafka-config
  422. configMap:
  423. name: {{ include "kafka.configmapName" . }}
  424. {{- end }}
  425. {{- if or .Values.log4j .Values.existingLog4jConfigMap }}
  426. - name: log4j-config
  427. configMap:
  428. name: {{ include "kafka.log4j.configMapName" . }}
  429. {{ end }}
  430. - name: scripts
  431. configMap:
  432. name: {{ include "kafka.fullname" . }}-scripts
  433. defaultMode: 0755
  434. {{- if and .Values.externalAccess.enabled .Values.externalAccess.autoDiscovery.enabled }}
  435. - name: shared
  436. emptyDir: {}
  437. {{- end }}
  438. {{- if .Values.metrics.jmx.enabled }}
  439. - name: jmx-config
  440. configMap:
  441. name: {{ include "kafka.metrics.jmx.configmapName" . }}
  442. {{- end }}
  443. {{- if (include "kafka.tlsEncryption" .) }}
  444. - name: kafka-certificates
  445. secret:
  446. secretName: {{ include "kafka.tlsSecretName" . }}
  447. defaultMode: 256
  448. {{- if (coalesce .Values.auth.tls.jksTruststoreSecret .Values.auth.jksTruststoreSecret) }}
  449. - name: kafka-truststore
  450. secret:
  451. secretName: {{ coalesce .Values.auth.tls.jksTruststoreSecret .Values.auth.jksTruststoreSecret }}
  452. defaultMode: 256
  453. {{- end }}
  454. {{- end }}
  455. {{- if .Values.extraVolumes }}
  456. {{- toYaml .Values.extraVolumes | nindent 8 }}
  457. {{- end }}
  458. {{- if not .Values.persistence.enabled }}
  459. - name: data
  460. emptyDir: {}
  461. {{- else if .Values.persistence.existingClaim }}
  462. - name: data
  463. persistentVolumeClaim:
  464. claimName: {{ printf "%s" (tpl .Values.persistence.existingClaim .) }}
  465. {{- end }}
  466. {{- if not .Values.logPersistence.enabled }}
  467. - name: logs
  468. emptyDir: {}
  469. {{- else if .Values.logPersistence.existingClaim }}
  470. - name: logs
  471. persistentVolumeClaim:
  472. claimName: {{ printf "%s" (tpl .Values.logPersistence.existingClaim .) }}
  473. {{- end }}
  474. {{- if or (and .Values.persistence.enabled (not .Values.persistence.existingClaim)) (and .Values.logPersistence.enabled (not .Values.logPersistence.existingClaim)) }}
  475. volumeClaimTemplates:
  476. {{- end }}
  477. {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
  478. - metadata:
  479. name: data
  480. {{- if .Values.persistence.annotations }}
  481. annotations: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }}
  482. {{- end }}
  483. spec:
  484. accessModes:
  485. {{- range .Values.persistence.accessModes }}
  486. - {{ . | quote }}
  487. {{- end }}
  488. resources:
  489. requests:
  490. storage: {{ .Values.persistence.size | quote }}
  491. {{ include "kafka.storageClass" . | nindent 8 }}
  492. {{- if .Values.persistence.selector }}
  493. selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 10 }}
  494. {{- end -}}
  495. {{- end }}
  496. {{- if and .Values.logPersistence.enabled (not .Values.logPersistence.existingClaim) }}
  497. - metadata:
  498. name: logs
  499. {{- if .Values.logPersistence.annotations }}
  500. annotations: {{- include "common.tplvalues.render" (dict "value" .Values.logPersistence.annotations "context" $) | nindent 10 }}
  501. {{- end }}
  502. spec:
  503. accessModes:
  504. {{- range .Values.logPersistence.accessModes }}
  505. - {{ . | quote }}
  506. {{- end }}
  507. resources:
  508. requests:
  509. storage: {{ .Values.logPersistence.size | quote }}
  510. {{ include "kafka.storageClass" . | nindent 8 }}
  511. {{- if .Values.logPersistence.selector }}
  512. selector: {{- include "common.tplvalues.render" (dict "value" .Values.logPersistence.selector "context" $) | nindent 10 }}
  513. {{- end -}}
  514. {{- end }}
  515. {{- end }}