python - 使用 Python SSH 实用程序执行 OpenShift 命令失败
问题描述
我正在尝试oc get nodes
使用 Python Paramiko SSH 客户端在 openshift 节点上执行 Open Shift 命令。
当我直接在节点上运行此命令时,它会执行并返回输出。但是,如果我尝试使用 ssh session 执行它,它会抛出以下错误。
['error: Missing or incomplete configuration info. Please login or point to an existing, complete config file:', '',
'1. Via the command-line flag --config',
'2. Via the KUBECONFIG environment variable',
'3. In your home directory as ~/.kube/config', '',
"To view or setup config directly use the 'config' command."]
我写的代码如下:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=ip_address,
username=username,
password=password)
client.exec_command('oc get nodes')
甚至尝试使用 运行命令ssh -i oc get nodes
,这会引发 Bash: oc 命令不存在。
使用的Python版本:Python3.7
我是 Python 新手,如果有任何库可以用来执行 oc 命令,请告诉我。
我感谢任何帮助,谢谢。
解决方案
推荐阅读
- rust - 如何为简单结构实现“索引”特征?
- nearprotocol - 交易/操作的气体限制是多少?
- c++ - 从 CMake 在 Eigen 中设置最大静态对齐
- excel - 如何使循环检查,总结单元格值并停在正确的位置
- c - c中的变量随机改变值
- racket - 如何在 Racket 中制作 HTML 表格边框
- vb.net - 如何计算已在 VB.NET 中的 datagridview 中检查的复选框
- microservices - jhipster 注册中心/控制中心向网关应用程序发送管理请求导致 401 未授权
- html - 为什么不使用填充作为显示?
- python - 我可以将 python 服务器与 kotlin 客户端连接起来吗?