Port forwarding lets a request to a local port reach an application listening at another endpoint. It is useful both for reaching a microservice in a Docker container and for testing a microservice that is normally accessible only inside a Kubernetes cluster. section 3.8.3 section 11.3.2
cd chapter-3/example-1 docker run -d -p 3000:3000 -e PORT=3000 video-streaming
Run the container with host port 3000 bound to container port 3000. The PORT environment variable separately tells the microservice which port to listen on. section 3.8.3
The two port settings must work together: binding a container port does not configure the microservice to listen on it. If host port 3000 is already allocated, stop the other application or choose another available port. Check the running mapping with docker container list; its PORTS column shows where host traffic goes. section 3.8.3
kubectl port-forward metadata-55bb6bdf58-7pjn2 6000:80
Forward local port 6000 to port 80 on the named Kubernetes pod. While the command runs, requests to http://localhost:6000 reach the internal microservice without exposing it to the outside world. section 11.3.2
Use kubectl port-forward <pod-name> [<local-port>:]<pod-port> when testing a different pod or port. This provides a way to check responses from an internal microservice or reach a cluster-hosted tool such as the RabbitMQ dashboard. Take care when inspecting customer-facing systems. section 11.3.2




