Skip to content

Commit

Permalink
[#4167] Kafka certificate authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ljupcovangelski committed Apr 26, 2024
1 parent 2f052cd commit 9c21ebd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions infrastructure/helm-chart/templates/config/kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ data:
{{- end }}
KAFKA_SCHEMA_REGISTRY_URL: {{ .Values.config.kafka.schemaRegistryUrl }}
KAFKA_COMMIT_INTERVAL_MS: "{{ .Values.config.kafka.commitInterval }}"
KAFKA_SASL_CA: |-
{{ .Values.config.kafka.saslCaCertificate | nindent 4 | trim }}
KAFKA_SASL_USERNAME: {{ .Values.config.kafka.saslUsername }}
KAFKA_SASL_PASSWORD: {{ .Values.config.kafka.saslPassword }}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ spec:
volumeMounts:
- name: kafka-create-topics
mountPath: /opt/provisioning
- name: kafka-config
mountPath: /opt/kafka/ca.pem
subPath: KAFKA_SASL_CA
initContainers:
- name: wait
image: "{{ .Values.global.busyboxImage }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ data:
REPLICAS=${KAFKA_MINIMUM_REPLICAS:-1}
AIRY_CORE_NAMESPACE=${AIRY_CORE_NAMESPACE:-}
AUTH_JAAS=${AUTH_JAAS:-}
KAFKA_SASL_USERNAME=${KAFKA_SASL_USERNAME:-}
KAFKA_SASL_PASSWORD=${KAFKA_SASL_PASSWORD:-}
KAFKA_SASL_CA=${KAFKA_SASL_CA:-}
if [ -n "${AIRY_CORE_NAMESPACE}" ]; then
AIRY_CORE_NAMESPACE="${AIRY_CORE_NAMESPACE}."
Expand All @@ -45,6 +48,18 @@ data:
echo "Using jaas authentication for connecting to Kafka"
fi
if [ -n "${KAFKA_SASL_CA}" ]; then
cat <<EOF > /opt/kafka/jaas.config
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.username=$KAFKA_SASL_USERNAME
sasl.password=$KAFKA_SASL_PASSWORD
sasl.ca.location=/opt/kafka/ca.pem
EOF
CONNECTION_OPTS+=(--command-config /opt/kafka/jaas.config)
echo "Using jaas authentication for connecting to Kafka"
fi
echo "Creating Kafka topics"
Expand Down

0 comments on commit 9c21ebd

Please sign in to comment.