jaas-secret.yaml 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {{- $port := print .Values.service.ports.client }}
  2. {{- $host := list }}
  3. {{- $bootstrapServers := list }}
  4. {{- range $i, $e := until (int .Values.replicaCount) }}
  5. {{- $broker := printf "%s-%s.%s-headless.%s.svc.%s" (include "common.names.fullname" $) (print $i) (include "common.names.fullname" $) $.Release.Namespace $.Values.clusterDomain }}
  6. {{- $host = append $host $broker }}
  7. {{- $bootstrapServers = append $bootstrapServers (printf "%s:%s" $broker $port) }}
  8. {{- end }}
  9. {{- $clientUsers := .Values.auth.sasl.jaas.clientUsers }}
  10. {{- $clientPasswords := .Values.auth.sasl.jaas.clientPasswords }}
  11. {{- if not $clientPasswords }}
  12. {{- $clientPasswords = list }}
  13. {{- range $clientUsers }}
  14. {{- $clientPasswords = append $clientPasswords (randAlphaNum 10) }}
  15. {{- end }}
  16. {{- end }}
  17. {{- if (include "kafka.createJaasSecret" .) }}
  18. apiVersion: v1
  19. kind: Secret
  20. metadata:
  21. name: {{ printf "%s-jaas" (include "common.names.fullname" .) }}
  22. namespace: {{ .Release.Namespace | quote }}
  23. labels: {{- include "common.labels.standard" . | nindent 4 }}
  24. {{- if .Values.commonLabels }}
  25. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  26. {{- end }}
  27. {{- if .Values.commonAnnotations }}
  28. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  29. {{- end }}
  30. type: Opaque
  31. data:
  32. {{- if (include "kafka.client.saslAuthentication" .) }}
  33. client-passwords: {{ join "," $clientPasswords | b64enc | quote }}
  34. system-user-password: {{ index $clientPasswords 0 | b64enc | quote }}
  35. {{- end }}
  36. {{- $zookeeperUser := .Values.auth.sasl.jaas.zookeeperUser }}
  37. {{- if and .Values.zookeeper.auth.client.enabled $zookeeperUser }}
  38. {{- $zookeeperPassword := .Values.auth.sasl.jaas.zookeeperPassword }}
  39. zookeeper-password: {{ default (randAlphaNum 10) $zookeeperPassword | b64enc | quote }}
  40. {{- end }}
  41. {{- if (include "kafka.interBroker.saslAuthentication" .) }}
  42. {{- $interBrokerPassword := .Values.auth.sasl.jaas.interBrokerPassword }}
  43. inter-broker-password: {{ default (randAlphaNum 10) $interBrokerPassword | b64enc | quote }}
  44. {{- end }}
  45. {{- end }}
  46. {{- if .Values.serviceBindings.enabled }}
  47. {{- if (include "kafka.client.saslAuthentication" .) }}
  48. {{- range $i, $e := until (len $clientUsers) }}
  49. ---
  50. apiVersion: v1
  51. kind: Secret
  52. metadata:
  53. name: {{ include "common.names.fullname" $ }}-svcbind-user-{{ $i }}
  54. namespace: {{ $.Release.Namespace | quote }}
  55. labels: {{- include "common.labels.standard" $ | nindent 4 }}
  56. {{- if $.Values.commonLabels }}
  57. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  58. {{- end }}
  59. {{- if $.Values.commonAnnotations }}
  60. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  61. {{- end }}
  62. type: servicebinding.io/kafka
  63. data:
  64. provider: {{ print "bitnami" | b64enc | quote }}
  65. type: {{ print "kafka" | b64enc | quote }}
  66. user: {{ index $clientUsers $i | b64enc | quote }}
  67. password: {{ index $clientPasswords $i | b64enc | quote }}
  68. host: {{ join "," $host | b64enc | quote }}
  69. port: {{ print $port | b64enc | quote }}
  70. bootstrap-servers: {{ join "," $bootstrapServers | b64enc | quote }}
  71. {{- end }}
  72. {{- else }}
  73. ---
  74. apiVersion: v1
  75. kind: Secret
  76. metadata:
  77. name: {{ include "common.names.fullname" . }}-svcbind
  78. namespace: {{ .Release.Namespace | quote }}
  79. labels: {{- include "common.labels.standard" . | nindent 4 }}
  80. {{- if .Values.commonLabels }}
  81. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  82. {{- end }}
  83. {{- if .Values.commonAnnotations }}
  84. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  85. {{- end }}
  86. type: servicebinding.io/kafka
  87. data:
  88. provider: {{ print "bitnami" | b64enc | quote }}
  89. type: {{ print "kafka" | b64enc | quote }}
  90. host: {{ join "," $host | b64enc | quote }}
  91. port: {{ print $port | b64enc | quote }}
  92. bootstrap-servers: {{ join "," $bootstrapServers | b64enc | quote }}
  93. {{- end }}
  94. {{- end }}