commands.sh

kubectl attach

all

Attach to a process that is already running inside an existing container.

More info →

Options (3)

-c, --containerboolean

Get output from a container in the specified pod

Example: kubectl attach {{pod_name}} {{[-c|--container]}} {{container_name}}
boolean

Get output from the first pod of a replica set

Example: kubectl attach {{[rs|replicaset]}}/{{replicaset_name}}
boolean

Create an interactive session with a pod

Example: kubectl attach {{pod_name}} {{[-it|--stdin --tty]}}

Examples (5)

Get output from a pod

Get output from a container in the specified pod

kubectl attach pod_name [-c|--container] container_name

Get output from the first pod of a replica set

kubectl attach [rs|replicaset]/replicaset_name

Create an interactive session with a pod

kubectl attach pod_name [-it|--stdin --tty]

Create an interactive session with a specific container from a pod

kubectl attach pod_name [-c|--container] container_name [-it|--stdin --tty]
made by @shridhargupta | data from tldr-pages