Skip to main content
Quick navigation

SNI Routing

View the full demo in realtime

You can either follow all the steps manually, or watch the recording

Review the docker compose environment

As can be seen from docker-compose.yaml the demo environment consists of the following services:

  • gateway1
  • gateway2
  • kafka-client
  • kafka1
  • kafka2
  • kafka3
  • schema-registry
  • zookeeper
cat docker-compose.yaml


rm *jks *key *p12 *crt

openssl req \
-x509 \
-newkey rsa:4096 \
-sha256 \
-days 3560 \
-nodes \
-keyout san.key \
-out san.crt \
-subj '/CN=username' \
-extensions san \
-config openssl.config

openssl pkcs12 \
-export \
-in san.crt \
-inkey san.key \
-name brokers \
-out san.p12 \
-password "pass:123456"

keytool \
-noprompt \
-alias brokers \
-importkeystore \
-deststorepass 123456 \
-destkeystore keystore.jks \
-srckeystore san.p12 \
-srcstoretype PKCS12 \
-srcstorepass 123456

keytool \
-noprompt \
-import \
-alias brokers \
-file san.crt \
-keypass 123456 \
-destkeystore truststore.jks \
-storepass 123456

echo """
security.protocol=SSL
ssl.truststore.location=/clientConfig/truststore.jks
ssl.truststore.password=123456
""" > client.config

Starting the docker environment

Start all your docker processes, wait for them to be up and ready, then run in background

  • --wait: Wait for services to be running|healthy. Implies detached mode.
  • --detach: Detached mode: Run containers in the background
docker compose up --detach --wait

Create a topic

docker compose exec kafka-client \
kafka-topics \
--bootstrap-server broker-sni-gateway1main1.gateway-sni.conduktor.local:6969 \
--create \
--replication-factor 3 \
--partitions 1 \
--topic clientTopic \
--command-config /clientConfig/client.config

Produce a record to clientTopic using gateway1

echo "Hello world 1" | docker compose exec -i kafka-client \
kafka-console-producer \
--bootstrap-server broker-sni-gateway1main1.gateway-sni.conduktor.local:6969 \
--topic clientTopic \
--producer.config /clientConfig/client.config

Produce a record to clientTopic using gateway2

echo "Hello world 2" | docker compose exec -i kafka-client \
kafka-console-producer \
--bootstrap-server broker-sni-gateway2main2.gateway-sni.conduktor.local:6969 \
--topic clientTopic \
--producer.config /clientConfig/client.config

Consume records from clientTopic

docker compose exec kafka-client \
kafka-console-consumer \
--bootstrap-server broker-sni-gateway1main3.gateway-sni.conduktor.local:6969 \
--topic clientTopic \
--from-beginning \
--max-messages 2 \
--consumer.config /clientConfig/client.config

Tearing down the docker environment

Remove all your docker processes and associated volumes

  • --volumes: Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers.
docker compose down --volumes