how to undo a kubectl port-forward

5/18/2016

If I forwarded a port using

kubectl port-forward mypod 9000:9000

How can I undo that so that I can bind port 9000 with another program?
Additionally, how can I test to see what ports are forwarded?

-- rideswitch
kubernetes

2 Answers

5/18/2016

The port is only forwarded while the kubectl process is running, so you can just kill the kubectl process that's forwarding the port. In most cases that'll just mean pressing CTRL+C in the terminal where the port-forward command is running.

-- Alex Robinson
Source: StackOverflow

12/27/2018

If it was launch in the background you can use the fg command to access it and then use ctrl + C

-- Doctor
Source: StackOverflow