attach
Get output from running pod mypod; use the ‘kubectl.kubernetes.io/default-container’ annotation # for selecting the container to be attached or the first container in the pod will be chosen
kubectl attach mypod
Get output from ruby-container from pod mypod
kubectl attach mypod -c ruby-container
Switch to raw terminal mode; sends stdin to ‘bash’ in ruby-container from pod mypod # and sends stdout/stderr from ‘bash’ back to the client
kubectl attach mypod -c ruby-container -i -t
Get output from the first pod of a replica set named nginx
kubectl attach rs/nginx
Attach to a process that is already running inside an existing container.
Usage
$ kubectl attach (POD | TYPE/NAME) -c CONTAINER
Flags
Name | Shorthand | Default | Usage |
---|---|---|---|
container | c | Container name. If omitted, use the kubectl.kubernetes.io/default-container annotation for selecting the container to be attached or the first container in the pod will be chosen | |
pod-running-timeout | 1m0s | The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running | |
quiet | q | false | Only print output from the remote session |
stdin | i | false | Pass stdin to the container |
tty | t | false | Stdin is a TTY |
当前内容版权归 Kubernetes 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Kubernetes .