kubernetes: kubectl.sh exec /bin/bash hangs after a while

Hi.

This seems to happen consistently on a series of containers i run. As a test case i’ve used a centos7 image running /usr/sbin/init:

cat test-pod.yaml

metadata:
  name: test
  labels:
    name: test
spec:
  containers:
    - name: testcontainer
      image: centos:centos7
      command:
        - /usr/sbin/init

, on which i then do:

kubectl.sh exec -p test -c testcontainer -i -t -- /bin/bash

After a certain period of time without providing any input (even if there’s a running command sending loads of output) the session hangs. A new session shows the command is still there (ps aux inside the container).

I don’t see this happen if i use docker exec directly:

sudo docker ps | grep testcontainer
a1e7be0e50d6        centos:7                                         "/usr/sbin/init"       56 seconds ago      Up 56 seconds                           k8s_testcontainer.50b617ca_test_default_2fdf35d7-09ed-11e5-917f-2c413815e0ae_05f06e3f     

sudo docker exec -it a1e7be0e50d6 /bin/bash

Due to this i assume it’s some extra kubernetes behavior. Let me know if i can provide any additional input - i couldn’t find anything in the log files.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 4
  • Comments: 29 (21 by maintainers)

Most upvoted comments

@deitch @RiaanLab Might it be the case that you are using this in AWS? I had the same issue and the reason was the ELB in front of the API server, by default it has a 60 seconds timeout. If there’s no traffic, the connection will be dropped.

1 hour would be much better than 5 minutes. Thanks.