Issue
I am trying to understand on how we can start a interactive shell on a desired container using Kubernetes client-python API.
I found that we can use connect_get_namespaced_pod_exec to run individual commands.
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)
Any help is most welcome.
Solution
from reading the tests I'd guess that the linked documentation already holds your answer. Use /bin/bash
as command and send any further commands through the stdin stream.
Invokation should be done with:
api.connect_get_namespaced_pod_exec('pod',
'namespace',
command='/bin/bash'
stderr=True,
stdin=True,
stdout=True,
tty=True)
The related kubectl exec --tty ...
client code is implemented the same way and could be used as a reference too.
Answered By - pagid Answer Checked By - Clifford M. (WPSolving Volunteer)