port-forward指令參數說明
# kubectl port-forward --help
Forward one or more local ports to a pod.
Examples:
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
kubectl port-forward mypod 5000 6000
# Listen on port 8888 locally, forwarding to 5000 in the pod
kubectl port-forward mypod 8888:5000
# Listen on a random port locally, forwarding to 5000 in the pod
kubectl port-forward mypod :5000
Options:
-p, --pod='': Pod name
Usage:
kubectl port-forward POD [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N] [options]
- 看完參數說明後你應該覺得他無法bind指定網卡啦,但是還是希望你們看一下官方文檔,因為這些指令會繼一些指令的
port-forward輔助工具安裝
$ wget https://www.kernel.org/pub/linux/utils/util-linux/v2.27/util-linux-2.27.tar.gz
$ tar -zxvf util-linux-2.27.tar.gz
$ cd util-linux-2.27
$ ./configure --without-ncurses && make nsenter
cp nsenter /usr/local/bin
kubectl port-forward $POD_NAME hostPort:containerPort