Kubernetes進入pod


首先類似於Docker容器,Kubernetes 使用kubectl 進行命令行操作

進入docker容器 :

docker exec -ti  <your-container-name>   /bin/sh

進入Kubernetes的pod:

kubectl exec -ti <your-pod-name>  -n <your-namespace>  -- /bin/sh

Overview of kubectl

kubectl exec - Execute a command against a container in a pod.

// Get output from running 'date' from pod <pod-name>. By default, output is from the first container.
$ kubectl exec <pod-name> date

// Get output from running 'date' in container <container-name> of pod <pod-name>.
$ kubectl exec <pod-name> -c <container-name> date

// Get an interactive TTY and run /bin/bash from pod <pod-name>. By default, output is from the first container.
$ kubectl exec -ti <pod-name> /bin/bash

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM