Skip to content

Port forward traffic from a Kubernetes pod#

Port forwarding in Kubernetes is a method that establishes a temporary connection between a local machine and a specific pod or a container. This connection enables local access to a service that runs within the pod or container. The port forwarding procedure simplifies debugging and facilitates the real-time monitoring without exposing services and data to the public internet.

In Lens Desktop, you can port forward without using the kubectl command-line tool:

  1. From the Pods tab of the cluster view, click on a pod.
  2. In Pod Details > Container, select a container with configured ports.
  3. Select one of the following options:

    • 8000/TCP to randomly assign the port and open a browser.
    • Forward to configure the parameters in the dialog menu.

      a GIF illustrating port forwarding

Managing port forwarding sessions#

You can see available port forwarding sessions in the Port Forwarding tab where the brief information about the sessions is displayed. You can also open a port forwarding in the browser, edit, stop, or delete the port forwarding session.