<p>Hey I'm running a kubernetes cluster and I want to run a command on all pods that belong to a specific service.</p>

<p>As far as I know kubectl exec can only run on a pod and tracking all my pods is a ridiculous amount of work (which is one of the benefits of services).</p>

<p>Is there any way or tool that gives you the ability to "broadcast" to all pods in a service?</p>

<p>Thanks in advance for your help! </p>

<p>Here's a simple example with kubectl pipe to xargs, printing env of each pod:</p>

<pre><code>k get pod \
    -l {your label selectors} \
    --field-selector=status.phase=Running \
    -o custom-columns=name:metadata.name --no-headers \
    | xargs -I{} kubectl exec {} env
</code></pre>
