NOTES.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. CHART NAME: {{ .Chart.Name }}
  2. CHART VERSION: {{ .Chart.Version }}
  3. APP VERSION: {{ .Chart.AppVersion }}
  4. {{- if .Values.diagnosticMode.enabled }}
  5. The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
  6. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
  7. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
  8. Get the list of pods by executing:
  9. kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }}
  10. Access the pod you want to debug by executing
  11. kubectl exec --namespace {{ .Release.Namespace }} -ti <NAME OF THE POD> -- bash
  12. In order to replicate the container startup scripts execute this command:
  13. /opt/bitnami/scripts/kafka/entrypoint.sh /opt/bitnami/scripts/kafka/run.sh
  14. {{- else }}
  15. {{- $replicaCount := int .Values.replicaCount -}}
  16. {{- $releaseNamespace := .Release.Namespace -}}
  17. {{- $clusterDomain := .Values.clusterDomain -}}
  18. {{- $fullname := include "common.names.fullname" . -}}
  19. {{- $clientProtocol := include "kafka.listenerType" (dict "protocol" .Values.auth.clientProtocol) -}}
  20. {{- $externalClientProtocol := include "kafka.listenerType" (dict "protocol" (include "kafka.externalClientProtocol" . )) -}}
  21. {{- $saslMechanisms := .Values.auth.sasl.mechanisms -}}
  22. {{- $tlsEndpointIdentificationAlgorithm := default "" .Values.auth.tls.endpointIdentificationAlgorithm -}}
  23. {{- $tlsPasswordSecret := printf "$(kubectl get secret %s --namespace %s -o jsonpath='{.data.password}' | base64 -d | cut -d , -f 1)" .Values.auth.tls.existingSecret $releaseNamespace -}}
  24. {{- $tlsPassword := ternary .Values.auth.tls.password $tlsPasswordSecret (eq .Values.auth.tls.existingSecret "") -}}
  25. {{- $servicePort := int .Values.service.ports.client -}}
  26. {{- if and (or (eq .Values.service.type "LoadBalancer") .Values.externalAccess.enabled) (eq $externalClientProtocol "PLAINTEXT") }}
  27. ---------------------------------------------------------------------------------------------
  28. WARNING
  29. By specifying "serviceType=LoadBalancer" and not configuring the authentication
  30. you have most likely exposed the Kafka service externally without any
  31. authentication mechanism.
  32. For security reasons, we strongly suggest that you switch to "ClusterIP" or
  33. "NodePort". As alternative, you can also configure the Kafka authentication.
  34. ---------------------------------------------------------------------------------------------
  35. {{- end }}
  36. ** Please be patient while the chart is being deployed **
  37. Kafka can be accessed by consumers via port {{ $servicePort }} on the following DNS name from within your cluster:
  38. {{ $fullname }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}
  39. Each Kafka broker can be accessed by producers via port {{ $servicePort }} on the following DNS name(s) from within your cluster:
  40. {{- $brokerList := list }}
  41. {{- range $e, $i := until $replicaCount }}
  42. {{- $brokerList = append $brokerList (printf "%s-%d.%s-headless.%s.svc.%s:%d" $fullname $i $fullname $releaseNamespace $clusterDomain $servicePort) }}
  43. {{- end }}
  44. {{ join "\n" $brokerList | nindent 4 }}
  45. {{- if (include "kafka.client.saslAuthentication" .) }}
  46. You need to configure your Kafka client to access using SASL authentication. To do so, you need to create the 'kafka_jaas.conf' and 'client.properties' configuration files with the content below:
  47. - kafka_jaas.conf:
  48. KafkaClient {
  49. {{- if $saslMechanisms | regexFind "scram" }}
  50. org.apache.kafka.common.security.scram.ScramLoginModule required
  51. {{- else }}
  52. org.apache.kafka.common.security.plain.PlainLoginModule required
  53. {{- end }}
  54. username="{{ index .Values.auth.sasl.jaas.clientUsers 0 }}"
  55. password="$(kubectl get secret {{ $fullname }}-jaas --namespace {{ $releaseNamespace }} -o jsonpath='{.data.client-passwords}' | base64 -d | cut -d , -f 1)";
  56. };
  57. - client.properties:
  58. security.protocol={{ $clientProtocol }}
  59. {{- if $saslMechanisms | regexFind "scram-sha-256" }}
  60. sasl.mechanism=SCRAM-SHA-256
  61. {{- else if $saslMechanisms | regexFind "scram-sha-512" }}
  62. sasl.mechanism=SCRAM-SHA-512
  63. {{- else }}
  64. sasl.mechanism=PLAIN
  65. {{- end }}
  66. {{- if eq $clientProtocol "SASL_SSL" }}
  67. ssl.truststore.type={{ upper .Values.auth.tls.type }}
  68. {{- if eq .Values.auth.tls.type "jks" }}
  69. ssl.truststore.location=/tmp/kafka.truststore.jks
  70. {{- if not (empty $tlsPassword) }}
  71. ssl.truststore.password={{ $tlsPassword }}
  72. {{- end }}
  73. {{- else if eq .Values.auth.tls.type "pem" }}
  74. ssl.truststore.certificates=-----BEGIN CERTIFICATE----- \
  75. ... \
  76. -----END CERTIFICATE-----
  77. {{- end }}
  78. {{- if eq $tlsEndpointIdentificationAlgorithm "" }}
  79. ssl.endpoint.identification.algorithm=
  80. {{- end }}
  81. {{- end }}
  82. {{- else if (include "kafka.client.tlsEncryption" .) }}
  83. You need to configure your Kafka client to access using TLS authentication. To do so, you need to create the 'client.properties' configuration file with the content below:
  84. security.protocol={{ $clientProtocol }}
  85. ssl.truststore.type={{ upper .Values.auth.tls.type }}
  86. {{- if eq .Values.auth.tls.type "jks" }}
  87. ssl.truststore.location=/tmp/kafka.truststore.{{ .Values.auth.tls.type }}
  88. {{- if not (empty $tlsPassword) }}
  89. ssl.truststore.password={{ $tlsPassword }}
  90. {{- end }}
  91. {{- else if eq .Values.auth.tls.type "pem" }}
  92. ssl.truststore.certificates=-----BEGIN CERTIFICATE----- \
  93. ... \
  94. -----END CERTIFICATE-----
  95. {{- end }}
  96. {{- if eq .Values.auth.clientProtocol "mtls" }}
  97. ssl.keystore.type={{ upper .Values.auth.tls.type }}
  98. {{- if eq .Values.auth.tls.type "jks" }}
  99. ssl.keystore.location=/tmp/client.keystore.jks
  100. {{- if not (empty $tlsPassword) }}
  101. ssl.keystore.password={{ $tlsPassword }}
  102. {{- end }}
  103. {{- else if eq .Values.auth.tls.type "pem" }}
  104. ssl.keystore.certificate.chain=-----BEGIN CERTIFICATE----- \
  105. ... \
  106. -----END CERTIFICATE-----
  107. ssl.keystore.key=-----BEGIN ENCRYPTED PRIVATE KEY----- \
  108. ... \
  109. -----END ENCRYPTED PRIVATE KEY-----
  110. {{- end }}
  111. {{- end }}
  112. {{- if eq $tlsEndpointIdentificationAlgorithm "" }}
  113. ssl.endpoint.identification.algorithm=
  114. {{- end }}
  115. {{- end }}
  116. To create a pod that you can use as a Kafka client run the following commands:
  117. kubectl run {{ $fullname }}-client --restart='Never' --image {{ template "kafka.image" . }} --namespace {{ $releaseNamespace }} --command -- sleep infinity
  118. {{- if or (include "kafka.client.saslAuthentication" .) (include "kafka.client.tlsEncryption" .) }}
  119. kubectl cp --namespace {{ $releaseNamespace }} /path/to/client.properties {{ $fullname }}-client:/tmp/client.properties
  120. {{- end }}
  121. {{- if (include "kafka.client.saslAuthentication" .) }}
  122. kubectl cp --namespace {{ $releaseNamespace }} /path/to/kafka_jaas.conf {{ $fullname }}-client:/tmp/kafka_jaas.conf
  123. {{- end }}
  124. {{- if and (include "kafka.client.tlsEncryption" .) (eq .Values.auth.tls.type "jks") }}
  125. kubectl cp --namespace {{ $releaseNamespace }} ./kafka.truststore.jks {{ $fullname }}-client:/tmp/kafka.truststore.jks
  126. {{- if eq .Values.auth.clientProtocol "mtls" }}
  127. kubectl cp --namespace {{ $releaseNamespace }} ./client.keystore.jks {{ $fullname }}-client:/tmp/client.keystore.jks
  128. {{- end }}
  129. {{- end }}
  130. kubectl exec --tty -i {{ $fullname }}-client --namespace {{ $releaseNamespace }} -- bash
  131. {{- if (include "kafka.client.saslAuthentication" .) }}
  132. export KAFKA_OPTS="-Djava.security.auth.login.config=/tmp/kafka_jaas.conf"
  133. {{- end }}
  134. PRODUCER:
  135. kafka-console-producer.sh \
  136. {{- if or (include "kafka.client.saslAuthentication" .) (include "kafka.client.tlsEncryption" .) }}
  137. --producer.config /tmp/client.properties \
  138. {{- end }}
  139. --broker-list {{ join "," $brokerList }} \
  140. --topic test
  141. CONSUMER:
  142. kafka-console-consumer.sh \
  143. {{- if or (include "kafka.client.saslAuthentication" .) (include "kafka.client.tlsEncryption" .) }}
  144. --consumer.config /tmp/client.properties \
  145. {{- end }}
  146. --bootstrap-server {{ $fullname }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:{{ .Values.service.ports.client }} \
  147. --topic test \
  148. --from-beginning
  149. {{- if .Values.externalAccess.enabled }}
  150. To connect to your Kafka server from outside the cluster, follow the instructions below:
  151. {{- if eq "NodePort" .Values.externalAccess.service.type }}
  152. {{- if .Values.externalAccess.service.domain }}
  153. Kafka brokers domain: Use your provided hostname to reach Kafka brokers, {{ .Values.externalAccess.service.domain }}
  154. {{- else }}
  155. Kafka brokers domain: You can get the external node IP from the Kafka configuration file with the following commands (Check the EXTERNAL listener)
  156. 1. Obtain the pod name:
  157. kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "kafka.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=kafka"
  158. 2. Obtain pod configuration:
  159. kubectl exec -it KAFKA_POD -- cat /opt/bitnami/kafka/config/server.properties | grep advertised.listeners
  160. {{- end }}
  161. Kafka brokers port: You will have a different node port for each Kafka broker. You can get the list of configured node ports using the command below:
  162. echo "$(kubectl get svc --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "kafka.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=kafka,pod" -o jsonpath='{.items[*].spec.ports[0].nodePort}' | tr ' ' '\n')"
  163. {{- else if contains "LoadBalancer" .Values.externalAccess.service.type }}
  164. NOTE: It may take a few minutes for the LoadBalancer IPs to be available.
  165. Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "kafka.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=kafka,pod" -w'
  166. Kafka Brokers domain: You will have a different external IP for each Kafka broker. You can get the list of external IPs using the command below:
  167. echo "$(kubectl get svc --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "kafka.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=kafka,pod" -o jsonpath='{.items[*].status.loadBalancer.ingress[0].ip}' | tr ' ' '\n')"
  168. Kafka Brokers port: {{ .Values.externalAccess.service.ports.external }}
  169. {{- else if eq "ClusterIP" .Values.externalAccess.service.type }}
  170. Kafka brokers domain: Use your provided hostname to reach Kafka brokers, {{ .Values.externalAccess.service.domain }}
  171. Kafka brokers port: You will have a different port for each Kafka broker starting at {{ .Values.externalAccess.service.ports.external }}
  172. {{- end }}
  173. {{- if not (eq $clientProtocol $externalClientProtocol) }}
  174. {{- if (include "kafka.client.saslAuthentication" .) }}
  175. You need to configure your Kafka client to access using SASL authentication. To do so, you need to create the 'kafka_jaas.conf' and 'client.properties' configuration files with the content below:
  176. - kafka_jaas.conf:
  177. KafkaClient {
  178. {{- if $saslMechanisms | regexFind "scram" }}
  179. org.apache.kafka.common.security.scram.ScramLoginModule required
  180. {{- else }}
  181. org.apache.kafka.common.security.plain.PlainLoginModule required
  182. {{- end }}
  183. username="{{ index .Values.auth.sasl.jaas.clientUsers 0 }}"
  184. password="$(kubectl get secret {{ $fullname }}-jaas --namespace {{ $releaseNamespace }} -o jsonpath='{.data.client-passwords}' | base64 -d | cut -d , -f 1)";
  185. };
  186. - client.properties:
  187. security.protocol={{ $externalClientProtocol }}
  188. {{- if $saslMechanisms | regexFind "scram-sha-256" }}
  189. sasl.mechanism=SCRAM-SHA-256
  190. {{- else if $saslMechanisms | regexFind "scram-sha-512" }}
  191. sasl.mechanism=SCRAM-SHA-512
  192. {{- else }}
  193. sasl.mechanism=PLAIN
  194. {{- end }}
  195. {{- if eq $externalClientProtocol "SASL_SSL" }}
  196. ssl.truststore.type={{ upper .Values.auth.tls.type }}
  197. {{- if eq .Values.auth.tls.type "jks" }}
  198. ssl.truststore.location=/tmp/kafka.truststore.jks
  199. {{- if not (empty $tlsPassword) }}
  200. ssl.truststore.password={{ $tlsPassword }}
  201. {{- end }}
  202. {{- else if eq .Values.auth.tls.type "pem" }}
  203. ssl.truststore.certificates=-----BEGIN CERTIFICATE----- \
  204. ... \
  205. -----END CERTIFICATE-----
  206. {{- end }}
  207. {{- if eq $tlsEndpointIdentificationAlgorithm "" }}
  208. ssl.endpoint.identification.algorithm=
  209. {{- end }}
  210. {{- end }}
  211. {{- else if (include "kafka.externalClient.tlsEncryption" .) }}
  212. You need to configure your Kafka client to access using TLS authentication. To do so, you need to create the 'client.properties' configuration file with the content below:
  213. security.protocol={{ $externalClientProtocol }}
  214. ssl.truststore.type={{ upper .Values.auth.tls.type }}
  215. {{- if eq .Values.auth.tls.type "jks" }}
  216. ssl.truststore.location=/tmp/kafka.truststore.{{ .Values.auth.tls.type }}
  217. {{- if not (empty $tlsPassword) }}
  218. ssl.truststore.password={{ $tlsPassword }}
  219. {{- end }}
  220. {{- else if eq .Values.auth.tls.type "pem" }}
  221. ssl.truststore.certificates=-----BEGIN CERTIFICATE----- \
  222. ... \
  223. -----END CERTIFICATE-----
  224. {{- end }}
  225. {{- if eq .Values.auth.externalClientProtocol "mtls" }}
  226. ssl.keystore.type={{ upper .Values.auth.tls.type }}
  227. {{- if eq .Values.auth.tls.type "jks" }}
  228. ssl.keystore.location=/tmp/client.keystore.jks
  229. {{- if not (empty $tlsPassword) }}
  230. ssl.keystore.password={{ $tlsPassword }}
  231. {{- end }}
  232. {{- else if eq .Values.auth.tls.type "pem" }}
  233. ssl.keystore.certificate.chain=-----BEGIN CERTIFICATE----- \
  234. ... \
  235. -----END CERTIFICATE-----
  236. ssl.keystore.key=-----BEGIN ENCRYPTED PRIVATE KEY----- \
  237. ... \
  238. -----END ENCRYPTED PRIVATE KEY-----
  239. {{- end }}
  240. {{- end }}
  241. {{- if eq $tlsEndpointIdentificationAlgorithm "" }}
  242. ssl.endpoint.identification.algorithm=
  243. {{- end }}
  244. {{- end }}
  245. {{- end }}
  246. {{- end }}
  247. {{- end }}
  248. {{- include "kafka.checkRollingTags" . }}
  249. {{- include "kafka.validateValues" . }}