Forrest logo
back to the kubectl tool

kubernetes:warp:ff75c

Forward one or more local ports of a service
$ kubectl port-forward svc/${service_name} ${local_port}:${service_port}
try on your machine

The command you provided is used to create a tunnel between a local port and a Kubernetes service.

Here's a breakdown of the command:

  • kubectl: It is the command-line tool for interacting with Kubernetes clusters.
  • port-forward: It is a kubectl sub-command that sets up a network proxy between a local port and a Kubernetes service, allowing you to access the service using your localhost.
  • svc/${service_name}: ${service_name} is a placeholder for the actual name of the Kubernetes service you want to forward ports for. svc/ is used as a prefix to specify that the name refers to a service.
  • ${local_port}:${service_port}: ${local_port} is the port number on your local machine where you want to receive the forwarded traffic. ${service_port} is the port number of the Kubernetes service to which you want to forward traffic.

So, the command establishes a connection between your local machine's ${local_port} and the ${service_port} of the ${service_name} Kubernetes service. Any traffic received on the ${local_port} will be forwarded to the ${service_name} service.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the kubectl tool