k8s与运行中pod进行
我们要进入一个pod,并且执行一条命令,得到命令的返回值:
kubectl命令是:
kubectl exec -it calijob-159-element-attr-7z776 --namespace=calibration -- /bin/bash -c 'python3 /workspace/work.py -i 16'
python接口调度api是:
def pod_exec(self, name, namespace, command): exec_command = ["/bin/sh", "-c", command] resp = stream(self.core_v1.connect_get_namespaced_pod_exec, name, namespace, command=exec_command, stderr=True, stdin=False, stdout=True, tty=False, _preload_content=False) try: while resp.is_open(): resp.update(timeout=1) if resp.peek_stdout(): return resp.read_stdout() if resp.peek_stderr(): return resp.read_stderr() except Exception as e: ding_msg("pod exec exception:{}".format(e)) raise e finally: resp.close()
全世界的程序员们联合起来吧!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2022-02-24 使用gunicorn部署flask项目