<p>I have more than one Kubernetes context. When I change contexts, I have been using <code>kill -9</code>  to kill the port-forward in order to redo the <code>pachtctl port-forward &amp;</code> command. I wonder if this is the right way of doing it.</p>

<p>In more detail:</p>

<p>I start off being in a Kubernetes context, we'll call it context_x. I then want to change context to my local context, called minikube. I also want to see my repos for this minikube context, but when I use <code>pachctl list-repo</code>, it still shows context_x's Pachyderm repos. When I do <code>pachctl port-forward</code>, I then get an error message about the address being already in use. So I have to ps -a, then kill -9 on those port forward processes, and then do pachctl port-forward command again.</p>

<p>An example of what I've been doing:</p>

<pre><code>$ kubectl config use-context minikube
$ pachctl list-repo #doesn't show minikube context's repos
$ pachctl port-forward &amp;
...several error messages along the lines of:
Unable to create listener: Error listen tcp4 127.0.0.1:30650: bind: address already in use
$ ps -a | grep forward
33964 ttys002    0:00.51 kubectl port-forward dash-12345678-abcde 38080:8080
33965 ttys002    0:00.51 kubectl port-forward dash-12345679-abcde 38081:8081
37245 ttys002    0:00.12 pachctl port-forward &amp;
37260 ttys002    0:00.20 kubectl port-forward pachd-4212312322-abcde 30650:650
$ kill -9 37260
$ pachctl port-forward &amp; #works as expected now
</code></pre>

<p>Also, kill -9 on the <code>pachctl port-forward</code> process 37245 doesn't work, it seems like I have to kill -9 on the <code>kubectl port-forward</code></p>

<p>You can specify the port if you want, as a different one using <code>-p</code> flag as mentioned in <a href="http://docs.pachyderm.io/en/latest/pachctl/pachctl_port-forward.html" rel="nofollow noreferrer">docs</a> Is there a reason of not doing it?</p>

<p>Also starting processes in background and then sending it a <code>SIGKILL</code> causes the resources to be unallocated properly so when you try to join again you might see it giving errors since it cannot allocate the same port again. So try running it without <code>&amp;</code> at the end.</p>

<p>So whenever you change the context all you need to do is <code>CTRL + C</code> and start it again, this will release the resources properly and gain thema gain.</p>
