<p>I am trying to understand on how we can start a interactive shell on a desired container using Kubernetes <a href="https://github.com/kubernetes-incubator/client-python" rel="nofollow noreferrer">client-python</a> API. </p>

<p>I found that we can use <a href="https://github.com/kubernetes-incubator/client-python/blob/master/kubernetes/docs/CoreV1Api.md#connect_get_namespaced_pod_exec" rel="nofollow noreferrer">connect_get_namespaced_pod_exec</a> to run individual commands. </p>

<p>Is there any way we can start a bash session on the desired pod and do somestuff specifically on the pod(I am using Docker Container)</p>

<p>Any help is most welcome.</p>

<p>from reading the tests I'd guess that the linked documentation already holds your answer. Use <code>/bin/bash</code> as command and send any further commands through the stdin stream.</p>

<p>Invokation should be done with:</p>

<pre><code>api.connect_get_namespaced_pod_exec('pod',
                                   'namespace',
                                    command='/bin/bash'
                                    stderr=True,
                                    stdin=True,
                                    stdout=True,
                                    tty=True)
</code></pre>

<p>The related <code>kubectl exec --tty ...</code> <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/exec.go" rel="nofollow noreferrer">client code</a> is implemented the same way and could be used as a reference too.</p>
