Port forwarding connects a convenient local port to a service running elsewhere. It lets you test a container or Kubernetes Service through localhost without assigning the service a public endpoint. section 3.4.3 section 2.2.1
Use port forwarding when you need to:
- Browse or query a containerized HTTP server locally, such as mapping host port 8080 to container port 80. section 2.2.1
- Reach a Kubernetes Service locally when a LoadBalancer Service has no external IP in a local cluster. section 3.4.3
- Debug a cloud Kubernetes Service or let a Docker container reach it through host.docker.internal. section 3.4.3
kubectl port-forward service/$SERVICE_NAME $FROM_PORT:$TO_PORT
Run kubectl port-forward with a Service name and a local-to-Service port pair: kubectl port-forward service/$SERVICE_NAME $FROM_PORT:$TO_PORT. section 3.4.3
Expose a Kubernetes time service
Forward the Service with kubectl port-forward service/timeserver 8080:80, then open http://localhost:8080. For a Docker container using Redis, forward 6379:6379 and connect to host.docker.internal on port 6379. section 3.4.3




