kubectl 转发端口流量

发布时间 2023-06-16 12:13:23作者: FLOWERS_WAN

 

之前运行了一次错误的命令,查看pid。

[root@k8s-master01 istio-1.17.1]# ps aux| grep kubectl
root     14819  0.0  0.0 112828  2296 pts/0    S+   11:30   0:00 grep --color=auto kubectl
root     19199  0.1  0.5 760028 43384 pts/0    Sl   11:23   0:00 kubectl -n istio-system port-forward prometheus-85949fddb-qdsd6 9090:9090

使用kill命令删除pid
[root@k8s-master01 istio-1.17.1]# kill -9 19199
[root@k8s-master01 istio-1.17.1]# ps aux| grep kubectl
root     15975  0.0  0.0 112828  2292 pts/0    S+   11:31   0:00 grep --color=auto kubectl
[1]+  Killed                  kubectl -n istio-system port-forward prometheus-85949fddb-qdsd6 9090:9090
[root@k8s-master01 istio-1.17.1]#


[root@k8s-master01 istio-1.17.1]# ps aux| grep kubectl
root     16579  0.0  0.0 112828  2296 pts/0    S+   11:31   0:00 grep --color=auto kubectl
[root@k8s-master01 istio-1.17.1]#

转发命令
[root@k8s-master01 istio-1.17.1]# kubectl -n istio-system port-forward prometheus-85949fddb-qdsd6 --address=0.0.0.0 9090:9090 &
[1] 18732
[root@k8s-master01 istio-1.17.1]# Forwarding from 0.0.0.0:9090 -> 9090