<p>Actually I am trying to make the following command in one command</p>

<pre><code>kubectl get pods| grep -oP 'mag[^\s]+'

output
mag121111
</code></pre>

<p>After that I will run the following command</p>

<pre><code>kubectl exec -itmag121111 bash
</code></pre>

<p>Now I am trying as following </p>

<pre><code> kubectl get pods| grep -oP 'mag[^\s]+' | kubectl exec -it bash
</code></pre>

<p>You can use <a href="https://github.com/thecasualcoder/kube-fzf" rel="nofollow noreferrer">kube-fzf</a>. It makes <code>exec into a pod(container)</code> and <code>portforward</code> super <strong>easy</strong>.</p>

<p>Refer <a href="https://github.com/thecasualcoder/kube-fzf#execpod-1" rel="nofollow noreferrer">this</a> for execpod</p>
