<p>I have a Kafka deployment and service deployed via Kubernetes. Each its pods have its internal IP and with a <strong>command</strong> like this</p>

<pre><code>kubectl describe services broker --namespace=kafka | grep Endpoints | awk '{print $2}'
</code></pre>

<p>I can get them all: <code>10.244.1.11:9092,10.244.2.15:9092,10.244.2.16:9092</code></p>

<p>I have another service deployed with Kubernetes, after my Kafka, that needs the result of that command as an environment variable KAFKA_BOOTSTRAP_SERVERS.</p>

<p>How can I get <strong>the result of that command into an environment variable</strong> in my service kubernetes YML file?</p>

Lobo
<p>You should develop a client program in python or go and using the service account that gets mounted in each container, hit the api server endpoint and retrieve Kafka endpoints. Parse the Json file output abd grab the actual broker ip addresses</p>
