使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在容器上执行 shell 命令
如需排查一些问题,您可能需要访问容器以直接在容器本身上执行命令。您可以通过 bash
shell 或通过 PowerShell 使用 kubectl exec
命令访问容器。
- 使用
kubectl describe pods
来查找您的集群中要连接的 Pod 的名称。
在以下示例中,该命令列出了 suitecrm-0 pod。
kubectl describe pods | grep Name
Name: suitecrm-0
- 使用以下方法之一执行 shell 命令:
- 使用
kubectl exec
打开 bash 命令 shell,您可在其中执行命令。
kubectl exec -it pod-name -- /bin/bash
以下示例获取了一个连接到 suitecrm-0 pod 的 shell:
kubectl exec -it suitecrm-0 -- /bin/bash
- 使用
kubectl exec
直接执行命令。
kubectl exec -it pod-name -- /bin/bash -c "command(s)"
以下示例列出了 suitecrm-0 pod 的根目录:
kubectl exec -it suitecrm-0 -- /bin/bash -c "ls /"
如需了解详情,请参阅 Kubernetes 文档。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2022-05-25。
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]