Kafka SSL + KERBEROS - Cheat Sheet Settings/Console commands
I found it tricky to make Kafka to work with SSL in a kerberized cluster. In this article I share ambari settings I used and console (producer/consumer) sample commands:
1- Install Ambari and deploy a cluster with Kafka
2- Kerberize cluster using Ambari (it can be AD Wizard, MIT Kerberos or Manual Keytabs)
3- Create keystore and truststore with proper certificates, more details here: http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.5.0/bk_security/content/ch_wire-ssl-certs.html
4- Change Kafka Settings on Ambari as below:
Kafka Brokers - Listerners: listeners=SASL_PLAINTEXT://localhost:6667, SASL_SSL://localhost:6668
Custom kafka-broker - security.inter.broker.protocol=SASL_PLAINTEXT
Custom kafka-broker - ssl.client.auth=none
Custom kafka-broker - ssl.key.password=YOUR-PASSWORD
Custom kafka-broker - ssl.keystore.location=/path-to-your-keystore
Custom kafka-broker - ssl.keystore.password=YOUR-PASSWORD
Custom kafka-broker - ssl.truststore.location=/path-to-your-truststore
Custom kafka-broker - ssl.truststore.password=YOUR-PASSWORD
5- Add kafka public certificate to default jdk truststore (cacerts) on node you are going to test console producer/consumer
6- Try producer/consumer SASL PLAINTEXT
#get kerberos ticket
kinit
<TYPE YOUR PASSWORD>
#producer plaintext
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list kafka-node1.domain:6667,kafka-node2.domain:6667 --topic test --security-protocol SASL_PLAINTEXT
#consumer plaintext
/usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --zookeeper zk-node1.domain:2181,zk-node2.domain:2181 --topic test --from-beginning --security-protocol SASL_PLAINTEXT
7- Try producer/consumer with SASL SSL
#kerberos ticket
kinit
<TYPE YOUR PASSWORD>
#producer ssl
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list kafka-node1.domain:6668,kafka-node2.domain:6668 --topic test --new-producer --producer-property "security.protocol=SASL_SSL"
#consumer ssl
/usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --new-consumer --bootstrap-server kafka-node1.domain:6668,kafka-node2.domain:6668 --topic test --from-beginning --security-protocol SASL_SSL
Tested with HDP 2.4.2 + Ambari 2.2

