繁体   English   中英

connect_get_namespaced_pod_exec 不返回任何内容

[英]connect_get_namespaced_pod_exec returns nothing

我想登录到 POD 并运行一些命令并基本上捕获 output。 但这并没有返回任何东西。

PS podname、namespace、containername 只是示例。 在我的示例中,我传递的是真实值。 此外,这些 POD 部署在 AWS 集群中

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')

找到解决方案。

原因 - 存在预加载内容。 它默认设置为 true。 如果设置为 false,则不会读取 api 响应。

在文档中的以下块中找到:

_preload_content:如果为 False,则 urllib3.HTTPResponse object 将在不读取/解码响应数据的情况下返回。 默认为真。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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