Port forwarding

Now we can use that name to ask kubectl to set up a proxy that will forward all traffic from a local port we specify to a port associated with the Pod we determine. The Node.js example runs on a different port than the Python example (port 3000 instead of port 5000), so the command needs to be updated accordingly:

kubectl port-forward nodejs-568183341-2bw5v 3000:3000

The output should be something like the following:

Forwarding from 127.0.0.1:3000 -> 3000Forwarding from [::1]:3000 -> 3000

This is forwarding any and all traffic that gets created on your local machine at TCP port 3000 to TCP port 3000 on the nodejs-568183341-2bw5v Pod.

Just as with the Python example, you don't get a Command Prompt back yet because the command ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.