Last active
August 18, 2024 13:05
-
-
Save tzapu/f47924daae9d64b65fdfaf92b64f587c to your computer and use it in GitHub Desktop.
connecting to a kubernets hosted kafka cluster from macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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