Accessing Kafka on host machine from minikube pods

Photo by Joel Fulgencio on Unsplash

ngrok to the rescue!

It’s as simple as …

ngrok tcp 9092(assuming Kafka is listening on default port 9092)
Session Status online
Account Abhishek Gupta (Plan: Free)
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding tcp://0.tcp.ngrok.io:16387 -> localhost:9092

Try it out

Create a topic

./kafka-topics.sh --create --topic test --partitions 1 --replication-factor 1 --zookeeper localhost:2181
./kafka-console-producer --broker-list 0.tcp.ngrok.io:16387 --property "parse.key=true" --property "key.separator=:" --topic test//prompt for data>hi:there
>ola:amigo
  • use the above URL for--broker-list and
  • use the correct topic name (one you created in the previous step)
  • and enter data when prompted..
./kafka-console-consumer --bootstrap-server 0.tcp.ngrok.io:16387 --topic test --property print.key=true --from-beginning
  • use the above URL for--bootstrap-server and
  • use the correct topic name (one you created in the previous step)

--

--

Principal Developer Advocate at AWS | I ❤️ Databases, Go, Kubernetes

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Gupta

Abhishek Gupta

Principal Developer Advocate at AWS | I ❤️ Databases, Go, Kubernetes