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

<pre><code>&gt;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.
</code></pre>

<p>How do I enable a TTY in my container yaml?</p>

<p>In order to have proper TTY and stdin when doing attach:</p>
<pre><code>kubectl attach -it POD -c CONTAINER
</code></pre>
<p>The container must be configured with <code>tty: true</code> and <code>stdin: true</code>.
By default both of those values are <code>false</code>: <a href="https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#debugging" rel="noreferrer">https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#debugging</a></p>
<p>Example Pod:</p>
<pre><code>spec:
      containers:
      - name: web
        image: web:latest
        tty: true
        stdin: true
</code></pre>
