Skip to content

kubectl port-forwarding for service access

kubectl port-forwarding is a method used to access services running within a Kubernetes cluster by creating a direct tunnel between a local port and a specific cluster resource.^[argocd-app-config__README.md]

Usage

To access a service, the command requires the target resource type (typically a service), the namespace, and a mapping of local to remote ports.^[argocd-app-config__README.md]

The general syntax is: kubectl port-forward svc/<service-name> <local-port>:<remote-port> -n <namespace>

For example, to access the ArgoCD UI locally on port 8080 (which routes to port 443 on the service), the following command is used^[argocd-app-config__README.md]: kubectl port-forward svc/argocd-server 8080:443 -n argocd

Sources

^[argocd-app-config__README.md]