Search code examples
kuberneteskubectl

kubectl - list all port forwards across all services?


I'm new to kubernetes and am wondering if there's a way for me to see a list of all currently configured port forwards using kubectl ?

I see there's a kubectl port-forward command, but it doesn't seem to list them, just set one up.


Solution

  • kubectl get svc --all-namespaces -o go-template='{{range .items}}{{range.spec.ports}}{{if .nodePort}}{{.nodePort}}{{"\n"}}{{end}}{{end}}{{end}}'
    

    Port forwards are listed in the services the above command should loop through all of them and print them out