前言

個人在使用 kubectl port-forward 來透過個人本機連線至叢集內的 Service 時,發現應用本身有很嚴重的延遲,並且終端出現很多如下的報錯:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
E0727 04:43:17.308460   41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
E0727 04:43:24.054587 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
E0727 04:43:27.345265 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
Handling connection for 3000
E0727 04:43:37.306154 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
E0727 04:43:37.383904 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
E0727 04:43:41.308084 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
E0727 04:43:42.641875 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
E0727 04:43:42.986275 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
E0727 04:43:44.239246 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
E0727 04:43:47.416765 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
E0727 04:43:57.452707 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
E0727 04:43:59.748437 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
E0727 04:44:07.487353 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
Handling connection for 3000
E0727 04:44:12.987901 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
E0727 04:44:17.522404 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
Handling connection for 3000
E0727 04:44:27.558770 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
Handling connection for 3000
E0727 04:44:37.593397 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
Handling connection for 3000
E0727 04:44:39.102161 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred
E0727 04:44:42.992369 41404 portforward.go:347] error creating error stream for port 3000 -> 3000: Timeout occurred

作法

後續將 kubectl 的版本替換成與 Kubernetes 相同的版本後,可以順利的訪問應用且終端沒有再出現報錯。