I want to fetch the list of broker ids in a cluster using kubectl exec command.
I am able to run the commands from inside the pod and fetch the list of broker ids, however I need to find the list without having to go inside.
I am using kafka helm charts from incubator and Kubernetes distribution which comes along with docker for Mac.
kubectl exec hissing-warthog-kafka-1 -- /usr/bin/zookeeper-shell hissing-warthog-zookeeper:2181 <<< "ls /brokers/ids"
Expected result: Welcome to ZooKeeper! JLine support is enabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null [zk: hissing-warthog-zookeeper:2181(CONNECTED) 0] ls /brokers/ids [0, 1, 2]
Actual result: Connecting to hissing-warthog-zookeeper:2181 Welcome to ZooKeeper! JLine support is enabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null [zk: hissing-warthog-zookeeper:2181(CONNECTED) 0]
It should work in following way:
kubectl exec hissing-warthog-kafka-1 -- /usr/bin/zookeeper-shell hissing-warthog-zookeeper:2181 -c ls /brokers/ids
Hope this helps.