podman-desktop/website/docs/kubernetes/port-forwarding.md
Anders Björklund 3e8445e5b8
fix: use prettier for formatting markdown (#10486)
* fix: use prettier for checking markdown

Since biome doesn't handle markdown yet, only svelte and code.

Restore the previous config, but skip "prettier-plugin-svelte".

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2024-12-30 13:41:13 +01:00

3.4 KiB

sidebar_position title description keywords tags
13 Configuring port forwarding Configuring port forwarding for a Kubernetes pod or service
podman desktop
podman
port forwarding
objects
kubernetes
Configuring-port-forwarding
port-forwarding

Configuring port forwarding

Within a Kubernetes cluster, you can access an application by its internal IP address. But, if you want to access the application from your local machine, use the port forwarding feature. Using UI, you can forward a local port to a port on the pod that runs your application. This way you can interact with the application running in a Kubernetes cluster from your local machine for debugging and testing purposes.

You can use the port forwarding feature for the pods and services running on a Kubernetes cluster. Also, you can perform port forwarding for any exposed ports.

Prerequisites

Make sure you have:

apiVersion: v1
kind: Pod
metadata:
  name: static-web
spec:
  containers:
    - image: nginx
      name: web
      ports:
        - containerPort: 80
          name: web
          protocol: TCP

Procedure: Start port forwarding

  1. Create a Kubernetes pod:

    1. Go to the Pods component page.
    2. Click Play Kubernetes YAML. play kubernetes yaml
    3. Select a Kubernetes YAML file, such as pod.yaml from your local machine.
    4. Set the Runtime field to Kubernetes cluster. set runtime field
    5. Click Play and then Done.
    6. View the newly created pod that runs on a Kubernetes cluster on the same page. view the newly created pod
    7. Click the name of the pod and select the Summary tab.
  2. Click the Forward... button corresponding to the port you want to use for port forwarding. forward button

  3. Click the Open button to view the running application in a web browser. open button

    :::note

    You can also start port forwarding from the Kubernetes > Services component page. After creating a service, click the name of the service and configure port forwarding in the Summary tab.

    :::

Procedure: Stop port forwarding

You can stop port forwarding by using one of the following ways:

Use the component page

  1. Go to the Pods or Kubernetes > Services page.
  2. Click the name of the Kubernetes pod or service for which you want to stop port fowarding.
  3. Click Remove in the Summary tab. The entry is removed from the Kubernetes > Port Forwarding page. using component page

Use the Port Forwarding page

  1. Go to the Kubernetes > Port Forwarding page.
  2. Click the Delete icon corresponding to the pod or servivce for which you want to stop port forwarding. The entry is removed from the page. using port forwarding page

Verification

  1. Go to the Kubernetes > Port Forwarding page.
  2. View the port forwarding details for Kubernetes pods and services. verifying port forwarding details