I have more than one Kubernetes context. When I change contexts, I have been using kill -9
to kill the port-forward in order to redo the pachtctl port-forward &
command. I wonder if this is the right way of doing it.
In more detail:
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 pachctl list-repo
, it still shows context_x's Pachyderm repos. When I do pachctl port-forward
, 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.
An example of what I've been doing:
$ kubectl config use-context minikube
$ pachctl list-repo #doesn't show minikube context's repos
$ pachctl port-forward &
...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 &
37260 ttys002 0:00.20 kubectl port-forward pachd-4212312322-abcde 30650:650
$ kill -9 37260
$ pachctl port-forward & #works as expected now
Also, kill -9 on the pachctl port-forward
process 37245 doesn't work, it seems like I have to kill -9 on the kubectl port-forward
Just wanted to update this answer for anyone who finds it—pachctl
now supports contexts, and a Pachyderm context includes a reference to its associated kubectl
context. When you switch to a new pachctl
context, pachctl
will now use the associated kubectl
context automatically (you'll still need to switch contexts in kubectl
)
You can specify the port if you want, as a different one using -p
flag as mentioned in docs Is there a reason of not doing it?
Also starting processes in background and then sending it a SIGKILL
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 &
at the end.
So whenever you change the context all you need to do is CTRL + C
and start it again, this will release the resources properly and gain thema gain.