官术网_书友最值得收藏!

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 -> 3000
Forwarding 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 is actively running to keep this particular tunnel alive. As a reminder, you can cancel or quit the kubectl command by pressing Ctrl + C and port forwarding will immediately end.

While the command is still running, open a browser and put in this URL: http://localhost:3000. The response should come back that says, Index Page. When we invoked the kubectl run command, I specifically choose port 3000 to match the default from Express.

主站蜘蛛池模板: 岳池县| 古交市| 和田县| 洪泽县| 澜沧| 郴州市| 车致| 连城县| 团风县| 荆门市| 祁东县| 石阡县| 宜宾市| 丹棱县| 常山县| 五寨县| 土默特左旗| 马鞍山市| 通榆县| 虎林市| 务川| 大英县| 棋牌| 台山市| 东丰县| 白沙| 曲松县| 海兴县| 新龙县| 阿尔山市| 普安县| 原平市| 霍山县| 阿克| 舞钢市| 昭觉县| 友谊县| 黔西| 广灵县| 修武县| 阆中市|