首先類似于Docker容器,Kubernetes 使用kubectl 進(jìn)行命令行操作
進(jìn)入docker容器 :
docker exec -ti <your-container-name> /bin/sh
進(jìn)入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