kubernetes-client/python-base

Is there any example of WSClient usage?

adubkov opened this issue · 1 comments

Hi,

Is there any example of WSClient usage to mimic kubectl exec -ti?

Not sure if i'm going right direction, but that is what I'm doing now:

ws = stream(self.kubectl.connect_get_namespaced_pod_exec, 'name, 'namespace', command=['/bin/sh'], stdout=True, stderr=True, stdin=True, tty=True, _preload_content=False)

for line in sys.stdin:
    ws.write_stdin(line)
    print(ws.read_all())

Problem is when I running it and entering ls in stdin it still return empty string.

Looks like I have to read each channel individually by ws.read_stdout() and ws.read_stderr()