2017-06-23 89 views

回答

4

看来最简单的方法是:

kubectl run tmp-shell --rm -i --tty --image centos -- /bin/bash 

注意

  • 这将弹出一个名为tmp-shell整体Deployment。这发生在您使用kubectl run的任何时候。
  • --rm确保这个Deployment及其所有组件在退出shell时被删除。如果省略--rm,则可以使用kubectl delete deploy/tmp-shell手动将其删除。
  • 如果您想要脱离外壳并使其能够重新连接,请省略--rm。在退出shell之后,您将能够重新附加:kubectl attach $pod-name -c $pod-container -i -t
  • 如果您的shell不启动,请检查您的群集是否资源不足(kubectl describe nodes)。您可以控制这个部署请求的资源与--requests

    --requests='': The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges. 
    

(由https://gc-taylor.com/blog/2016/10/31/fire-up-an-interactive-bash-pod-within-a-kubernetes-cluster启发)

相关问题