Port-Forward Kubernetes service or pod port to local port

Port-Forward Kubernetes service or pod port to local port

In Kubernetes you often need to troubleshoot an application and one of the first step is to port-forward the container port to a local port to check if it's all working.

It's very simple, but still I have to check the syntax every time:

kubectl --namespace default port-forward service/default-svc 8080:80

Or if you need to port-forward directly a pod

kubectl --namespace default port-forward pod/mypod 8888:5000