externalIp of zk and kf
Closed this issue · 3 comments
alexbel1980 commented
Hello, can you please describe how can I expose zk and kf to be available from outside of k8s cluster?
StevenACoffman commented
If you need to expose Kafka outside of the Kubernetes cluster, you should be able to do:
kubectl apply -f ./outside-services
This will allow you to access Kafka outside your kubernetes cluster like so:
#!/bin/bash -x
function join_by { local IFS="$1"; shift; echo "$*"; }
BOOTSTRAP_ARRAY=()
POD_NAME_ARRAY=("kafka-0" "kafka-1" "kafka-2")
for POD_NAME in "${POD_NAME_ARRAY[@]}"
do
BOOTSTRAP_IP=$(kubectl get pods ${POD_NAME} -n kafka -o jsonpath='{.metadata.labels.kafka-listener-outside-host}')
BOOTSTRAP_PORT=$(kubectl get pods ${POD_NAME} -n kafka -o jsonpath='{.metadata.labels.kafka-listener-outside-port}')
BOOTSTRAP_ARRAY+=("$BOOTSTRAP_IP:$BOOTSTRAP_PORT")
done
BOOTSTRAP=$(join_by , "${BOOTSTRAP_ARRAY[@]}")
docker run --rm -t solsson/kafkacat -C -b $BOOTSTRAP -t k8s-firehose -o -10
If you want to expose Zookeeper, you can do something similar, but mostly you shouldn't need to. Connecting to Zookeeper first is generally just to get the bootstrap IP and ports.
alexbel1980 commented
Thanks