使用kubectl run/exec -i --tty
功能运行v1.5.1
时出现问题。
发送数据时,连接不会中断。因此,当我启动一个交互式容器会话,使用一个不时输出一些内容的脚本时,它似乎可以工作。
基于此,我创建了一个讨厌的解决方法,以保持容器会话的运行,而不需要我的交互。这些会话过早终止真的很烦人。它们会留下垃圾,这些垃圾需要清理,以防您连接到正在运行的生产容器。
解决方法(每隔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问题重新发布
我现在已经解决了这个问题。该问题是由通过AWS LoadBalancer(ELB或ALB)提供服务的Kubernetes API引起的。这些会在超时后终止连接,导致CCD_4和Kubernetes API服务器之间的连接断开。
这本身并不是Kubernetes的问题,而是与如何向最终用户提供Kubernetesneneneba API服务器有关。在这种情况下,通过负载平衡器。
快速解决方法:增加超时时间或偶尔通过有线发送数据以保持连接畅通。