Skip to content

Instantly share code, notes, and snippets.

@mihkels
Created August 31, 2021 16:11
Show Gist options
  • Save mihkels/e5c80dab8f95b5cb4c55f09f958f71f6 to your computer and use it in GitHub Desktop.
Save mihkels/e5c80dab8f95b5cb4c55f09f958f71f6 to your computer and use it in GitHub Desktop.
Bitnami Docker Kafka image with SSL

Topic creation command:

kafka-topics --bootstrap-server localhost:9093 --create --replication-factor 1 --partitions 1 --topic demo_test --command-config /tmp/props/consumer-ssl.properties

Producer command:

kafka-console-producer --bootstrap-server localhost:9093 --topic demo_test --producer.config /tmp/props/consumer-ssl.properties

Consumer command:

kafka-console-consumer --bootstrap-server localhost:9093 --topic demo_test --consumer.config /tmp/props/consumer-ssl.properties --from-beginning
security.protocol=SSL
ssl.endpoint.identification.algorithm=
ssl.truststore.location=/tmp/props/kafka.truststore.jks
ssl.truststore.password=secret
ssl.keystore.location=/tmp/props/kafka.keystore.jks
ssl.keystore.password=secret
ssl.key.password=secret
version: "3.7"
services:
zookeeper:
image: docker.io/bitnami/zookeeper:latest
hostname: zookeeper
ports:
- 2181:2181
volumes:
- ./data/zookeeper:/bitnami
environment:
ALLOW_ANONYMOUS_LOGIN: yes
kafka:
image: docker.io/bitnami/kafka:latest
ports:
- 9093:9093
volumes:
- ./data/kafka:/bitnami:rw
- ./secret/kafka.keystore.jks:/opt/bitnami/kafka/config/certs/kafka.keystore.jks:ro
- ./secret/kafka.truststore.jks:/opt/bitnami/kafka/config/certs/kafka.truststore.jks:ro
environment:
KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_LISTENERS: CLIENT://:9092,EXTERNAL://:9093
KAFKA_CFG_ADVERTISED_LISTENERS: CLIENT://kafka:9092,EXTERNAL://localhost:9093
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CLIENT:PLAINTEXT,EXTERNAL:SSL,SSL:SSL,PLAINTEXT:PLAINTEXT
KAFKA_CFG_SSL_KEYSTORE_LOCATION: /opt/bitnami/kafka/config/certs/kafka.keystore.jks
KAFKA_CFG_SSL_KEYSTORE_PASSWORD: secret
KAFKA_CFG_SSL_KEY_PASSWORD: secret
KAFKA_CFG_SSL_TRUSTSTORE_LOCATION: /opt/bitnami/kafka/config/certs/kafka.truststore.jks
KAFKA_CFG_SSL_TRUSTSTORE_PASSWORD: secret
KAFKA_CFG_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM:
KAFKA_CFG_ZOOKEEPER_PROTOCOL: PLAINTEXT
KAFKA_SECURITY_PROTOCOL: SSL
KAFKA_SECURITY_INTER_BROKER_PROTOCOL: CLIENT
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: CLIENT
depends_on:
- zookeeper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment