Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
connecting to a kubernets hosted kafka cluster from macOS
# you will need to alias the internal kube IPs to your loopback interface
# get pods with IPs
kubectl get pods -n kafka -o wide
# add aliases
sudo ifconfig lo0 100.101.168.109 alias
sudo ifconfig lo0 100.117.38.251 alias
sudo ifconfig lo0 100.121.158.154 alias
# start port forwarding for each kafka brokers
kubectl port-forward -n kafka kafka-kafka-0 9092:9092
kubectl port-forward -n kafka kafka-kafka-1 9093:9092
kubectl port-forward -n kafka kafka-kafka-2 9094:9092
# add redirect rules to macOS's packet filter
echo "
rdr pass on lo0 inet proto tcp from any to 100.121.158.154 port 9092 -> 127.0.0.1 port 9092
rdr pass on lo0 inet proto tcp from any to 100.117.38.251 port 9092 -> 127.0.0.1 port 9093
rdr pass on lo0 inet proto tcp from any to 100.101.168.109 port 9092 -> 127.0.0.1 port 9094
" | sudo pfctl -ef -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.