简体   繁体   中英

connect_get_namespaced_pod_exec returns nothing

I want to login into a POD and run few commands and basically capture output. But this is returning nothing.

PS podname, namespace, containername are just examples. In my examples, am passing real values. Also, These PODs are deployed in AWS Cluster

def runCommand(self, command, podname, namespace,servicename ):
            resp = stream(self.api.connect_get_namespaced_pod_exec,
                  podname,
                  namespace,
                  command=command,
                  container= servicename,
                  stderr=True, stdin=False,
                  stdout=True, tty=False,
                  _preload_content=False)
            
            return resp.read_stdout()

runCommand(['ls'], 'podname','namespace', 'containername')

Found solution.

Reason - preload content is present. It is set to true by default. If you make it false, api response will not be read.

Found below chunk in the documentation:

_preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM