使用v1.5.1
功能运行kubectl run/exec -i --tty
时遇到问题。
发送数据时,连接不会中断。所以,当我启动一个交互式容器会话时,脚本会不时地输出一些东西,它似乎有效。
基于此,我创建了一个讨厌的解决方法来保持我的容器会话继续进行,而没有我的交互。这些会议过早终止真的很烦人。他们留下垃圾,需要清理,以防你附加到正在运行的生产容器。
解决方法(每隔59秒将一个空格字符打印到STDERR作为后台进程):
# within your container session
$ while :; do sleep 59; echo -n ' ' >&2; done &
当我不启动这样的脚本时,请参阅以下输出。 它表明交互式会话在约2分钟内过早终止。
如果您正在利用此功能来调试正在运行的应用程序和容器安装,那真的很烦人。
$ time kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
Waiting for pod default/busybox to be running, status is Pending, pod ready: false
If you don't see a command prompt, try pressing enter.
/ # Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
Waiting for pod default/busybox to terminate, status is Running
error: timed out waiting for the condition
real 2m4.657s
从此Github Issue重新发帖。
答案 0 :(得分:0)
我现在已经解决了这个问题。
该问题是由通过AWS LoadBalancer(ELB或ALB)提供Kubernetes API引起的。这些会在超时后终止连接,导致kubectl
与Kubernetes API服务器之间断开连接。
这本身不是Kubernetes的问题,它与您如何向最终用户提供Kubernetes API服务器有关。在这种情况下,需要使用负载均衡器。
快速解决方法:增加超时时间或不时通过电线发送数据以保持连接打开。