因目前開發中的項目不能公開,每次想訪問服務只能連入VPN真有點不方便。但原來可透過kubectl port-forward 訪問服務的,操作如下:
kubectl port-forward pods/{the port name} {local port}:{remote port} -n {namespace}
如使用VSCODE,只要找到POD再按右鍵,選擇Port Forward,在提示輸入{local port}:{remote port}即可。
WSL 不能連入本地端口?
當我localport選用8080、10000等端口,在Windows上的Chrome輸入 http://localhost:8080沒反應,在WSL Terminal使用netstat見到有8080 listening port,但Windows cmd netstat又沒看到。最後網上建議查看exclude port range:
c:\> netsh int ipv4 show excludedportrange protocol=tcp
Protocol tcp Port Exclusion Ranges
Start Port End Port
---------- --------
1541 1640
1641 1740
1741 1840
1841 1940
...
12668 12767
12768 12867
12868 12967
12968 13067
20807 20807
50000 50059 *
* - Administered port exclusions.
現在把 port forward中的local port 改成 50000,成功了!