<p>I want to fetch the list of broker ids in a cluster using kubectl exec command.</p>

<p>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.</p>

<p>I am using kafka <a href="https://github.com/helm/charts/tree/master/incubator/kafka" rel="nofollow noreferrer">helm charts from incubator</a> and Kubernetes distribution which comes along with docker for Mac.</p>

<pre><code>kubectl exec hissing-warthog-kafka-1 -- /usr/bin/zookeeper-shell hissing-warthog-zookeeper:2181 &lt;&lt;&lt; "ls /brokers/ids"
</code></pre>

<p><strong>Expected result:</strong>
Welcome to ZooKeeper!
JLine support is enabled</p>

<p>WATCHER::</p>

<p>WatchedEvent state:SyncConnected type:None path:null
[zk: hissing-warthog-zookeeper:2181(CONNECTED) 0] ls /brokers/ids
[0, 1, 2]</p>

<p><strong>Actual result:</strong>
Connecting to hissing-warthog-zookeeper:2181
Welcome to ZooKeeper!
JLine support is enabled</p>

<p>WATCHER::</p>

<p>WatchedEvent state:SyncConnected type:None path:null
[zk: hissing-warthog-zookeeper:2181(CONNECTED) 0]</p>

amankedia
<p>It should work in following way:</p>

<pre><code>kubectl exec hissing-warthog-kafka-1 -- /usr/bin/zookeeper-shell hissing-warthog-zookeeper:2181 -c ls /brokers/ids
</code></pre>

<p>Hope this helps.</p>
