<p>I want to create a script that will run <code>port-forwarding</code> for a pod automatically, for specific pod name(app3, I've multiple apps in this namespace and I need to run just for <code>app3</code> ) when I run this script.</p>
<p>e.g.</p>
<p><code>kubectl port-forward pods/app3-86499b66d-dfwf7  8000:8000  -n web</code></p>
<p>I've started with</p>
<p><code>kubectl get pod -n webide-system | grep app3</code></p>
<p>The output is:</p>
<p><code>app3-86499b66d-dfwf7                                 1/1     Running     0          18h</code></p>
<p>However,Im not sure how to take the output, which is the pod name and run the port forwarding to it
The following in bold is constant</p>
<p><strong>pods/app3</strong>-86499b66d-dfwf7</p>
<p>And this is changing for each deployment</p>
<pre><code>-86499b66d-dfwf7
</code></pre>
<p>Any idea how to make it works with a script?</p>

<pre><code>POD_NAME=`kubectl get pod -n webide-system | grep app3 | sed 's/ .*//'`

kubectl port-forward pods/$POD_NAME  8000:8000  -n web
</code></pre>
