我使用端口转发来暴露我的服务前端如下:
kubectl port-forward -n hotel-reserv svc/frontend 30096:5000
之后,我使用工作负载生成器(即wrk2)向
http://localhost:30096
发送请求,有时会遇到以下错误消息:
E0323 16:12:26.434292 2362409 portforward.go:345] error creating error stream for port 30096 -> 5000: Timeout occurred
E0323 16:12:26.435372 2362409 portforward.go:368] error creating forwarding stream for port 30096 -> 5000: Timeout occurred
# Or error msgs like below
E0323 16:08:08.572355 2360819 portforward.go:407] an error occurred forwarding 30096 -> 5000: error forwarding port 5000 to pod d4cdf91e5f8726fc70f134ad3496ab185312b490c7c9022758a09e51b751b002, uid : container not running (d4cdf91e5f8726fc70f134ad3496ab185312b490c7c9022758a09e51b751b002)
后面的消息有时意味着端口转发将停止,我需要再次执行命令(即
kubectl port-forward ...
)。
有解决这些错误的方法吗? 出现一些错误后如何保持
port-forward
工作或重启?或者我可以在前端服务的.yaml
中添加一些字段以保持其端口转发状态吗?