kubectl port-forward
Pod Service,
Syntax
kubectl port-forward <resource> <local-port>:<remote-port> [flags]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
--address |
( 127.0.0.1) | kubectl port-forward pod/web --address 0.0.0.0 8080:80 |
Advanced |
-n --namespace |
kubectl port-forward svc/web -n production 8080:80 |
Common |
Examples
Pod
kubectl port-forward pod/web-app-6f7b8c9d-k2m4n 8080:80
8080 Pod 80
Service
kubectl port-forward svc/my-service 3000:80
Service, Pod
kubectl port-forward svc/mysql 3306:3306
MySQL
kubectl port-forward --address 0.0.0.0 svc/web 8080:80
()
Common Errors
unable to forward port: pod is not runningPod Running, Pod
address already in use,
Tips
- port-forward,
- Service Pod, Pod New
- Ctrl+C