123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- {{- if .Values.provisioning.enabled }}
- kind: Job
- apiVersion: batch/v1
- metadata:
- name: {{ include "kafka.fullname" . }}-provisioning
- labels: {{- include "common.labels.standard" . | nindent 4 }}
- app.kubernetes.io/component: kafka-provisioning
- {{- if .Values.commonLabels }}
- {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
- {{- end }}
- annotations:
- helm.sh/hook: post-install,post-upgrade
- helm.sh/hook-delete-policy: before-hook-creation
- {{- if .Values.commonAnnotations }}
- {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
- {{- end }}
- spec:
- template:
- metadata:
- labels: {{- include "common.labels.standard" . | nindent 8 }}
- app.kubernetes.io/component: kafka-provisioning
- {{- if .Values.podLabels }}
- {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
- {{- end }}
- annotations:
- {{- if .Values.provisioning.podAnnotations }}
- {{- include "common.tplvalues.render" (dict "value" .Values.provisioning.podAnnotations "context" $) | nindent 8 }}
- {{- end }}
- spec:
- {{- include "kafka.imagePullSecrets" . | nindent 6 }}
- {{- if .Values.provisioning.schedulerName }}
- schedulerName: {{ .Values.provisioning.schedulerName | quote }}
- {{- end }}
- restartPolicy: OnFailure
- terminationGracePeriodSeconds: 0
- initContainers:
- - name: wait-for-available-kafka
- image: {{ include "kafka.provisioning.image" . }}
- imagePullPolicy: {{ .Values.provisioning.image.pullPolicy | quote }}
- command:
- - /bin/bash
- - -c
- - >-
- set -e;
- wait-for-port \
- --host={{ include "kafka.fullname" . }} \
- --state=inuse \
- --timeout=120 \
- {{ .Values.service.port | int64 }};
- echo "Kafka is available";
- containers:
- - name: kafka-provisioning
- image: {{ include "kafka.provisioning.image" . }}
- imagePullPolicy: {{ .Values.provisioning.image.pullPolicy | quote }}
- command:
- {{- if .Values.provisioning.command }}
- {{- include "common.tplvalues.render" (dict "value" .Values.provisioning.command "context" $) | nindent 12 }}
- {{- else }}
- - /bin/bash
- {{- end }}
- args:
- {{- if .Values.provisioning.args }}
- {{- include "common.tplvalues.render" (dict "value" .Values.provisioning.args "context" $) | nindent 12 }}
- {{- else }}
- - -ec
- - |
- {{- $bootstrapServer := printf "%s:%d" (include "kafka.fullname" .) (.Values.service.port | int64) }}
- {{- range $topic := .Values.provisioning.topics }}
- echo "Ensure topic '{{ $topic.name }}' exists"
- /opt/bitnami/kafka/bin/kafka-topics.sh \
- --create \
- --if-not-exists \
- --bootstrap-server {{ $bootstrapServer }} \
- --replication-factor {{ $topic.replicationFactor | default $.Values.provisioning.replicationFactor }} \
- --partitions {{ $topic.partitions | default $.Values.provisioning.numPartitions }} \
- {{- range $name, $value := $topic.config }}
- --config {{ $name }}={{ $value }} \
- {{- end }}
- --topic {{ $topic.name }}
- {{- end }}
- echo "Provisioning succeeded"
- {{- end }}
- env:
- - name: BITNAMI_DEBUG
- value: {{ ternary "true" "false" .Values.provisioning.image.debug | quote }}
- {{- if .Values.provisioning.resources }}
- resources: {{- toYaml .Values.provisioning.resources | nindent 12 }}
- {{- end }}
- volumeMounts:
- {{- if or .Values.config .Values.existingConfigmap }}
- - name: kafka-config
- mountPath: {{ .Values.persistence.mountPath }}/config/server.properties
- subPath: server.properties
- {{- end }}
- {{- if or .Values.log4j .Values.existingLog4jConfigMap }}
- - name: log4j-config
- mountPath: {{ .Values.persistence.mountPath }}/config/log4j.properties
- subPath: log4j.properties
- {{- end }}
- {{- if (include "kafka.tlsEncryption" .) }}
- - name: kafka-certificates
- mountPath: /certs
- readOnly: true
- {{- end }}
- volumes:
- {{- if or .Values.config .Values.existingConfigmap }}
- - name: kafka-config
- configMap:
- name: {{ include "kafka.configmapName" . }}
- {{- end }}
- {{- if or .Values.log4j .Values.existingLog4jConfigMap }}
- - name: log4j-config
- configMap:
- name: {{ include "kafka.log4j.configMapName" . }}
- {{ end }}
- {{- if (include "kafka.tlsEncryption" .) }}
- - name: kafka-certificates
- secret:
- secretName: {{ include "kafka.tlsSecretName" . }}
- defaultMode: 256
- {{- end }}
- {{- end }}
|