Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl attach: Unable to use a TTY - container es-node did not allocate one

I am trying to attach to a running container in Kubernetes, however I get the error message below.

>kubectl attach -it es-client-2756725635-4rk43 -c es-node
Unable to use a TTY - container es-node did not allocate one
If you don't see a command prompt, try pressing enter.

How do I enable a TTY in my container yaml?

like image 399
speedplane Avatar asked Oct 06 '16 01:10

speedplane


2 Answers

The reason why it's failiing is because you're not passing the bash argument. This causes a failure when trying to create a tty connection.

Please try:

kubectl exec -it [POD-NAME] -c [CONTAINER-NAME] bash
like image 38
Alex Luis Arias Avatar answered Sep 16 '22 19:09

Alex Luis Arias


In order to have proper TTY and stdin when doing attach:

kubectl attach -it POD -c CONTAINER

The container must be configured with tty: true and stdin: true. By default both of those values are false: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#debugging

Example Pod:

spec:
      containers:
      - name: web
        image: web:latest
        tty: true
        stdin: true
like image 108
Alex Plugaru Avatar answered Sep 16 '22 19:09

Alex Plugaru