1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl attach - Attach to a running container
10
11
12

SYNOPSIS

14       kubectl attach [OPTIONS]
15
16
17

DESCRIPTION

19       Attach  to  a  process  that is already running inside an existing con‐
20       tainer.
21
22
23

OPTIONS

25       -c, --container=""      Container name. If omitted, the first container
26       in the pod will be chosen
27
28
29       --pod-running-timeout=1m0s      The length of time (like 5s, 2m, or 3h,
30       higher than zero) to wait until at least one pod is running
31
32
33       -i, --stdin=false      Pass stdin to the container
34
35
36       -t, --tty=false      Stdin is a TTY
37
38
39

OPTIONS INHERITED FROM PARENT COMMANDS

41       --add-dir-header=false      If true, adds the  file  directory  to  the
42       header of the log messages
43
44
45       --alsologtostderr=false      log to standard error as well as files
46
47
48       --application-metrics-count-limit=100       Max  number  of application
49       metrics to store (per container)
50
51
52       --as=""      Username to impersonate for the operation
53
54
55       --as-group=[]      Group to impersonate for the  operation,  this  flag
56       can be repeated to specify multiple groups.
57
58
59       --azure-container-registry-config=""       Path  to the file containing
60       Azure container registry configuration information.
61
62
63       --boot-id-file="/proc/sys/kernel/random/boot_id"        Comma-separated
64       list of files to check for boot-id. Use the first one that exists.
65
66
67       --cache-dir="/builddir/.kube/cache"      Default cache directory
68
69
70       --certificate-authority=""      Path to a cert file for the certificate
71       authority
72
73
74       --client-certificate=""      Path to a client certificate file for TLS
75
76
77       --client-key=""      Path to a client key file for TLS
78
79
80       --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
81            CIDRs  opened  in  GCE  firewall  for  L7 LB traffic proxy  health
82       checks
83
84
85       --cloud-provider-gce-lb-src-cidrs=130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
86            CIDRs  opened  in  GCE  firewall  for  L4 LB traffic proxy  health
87       checks
88
89
90       --cluster=""      The name of the kubeconfig cluster to use
91
92
93       --container-hints="/etc/cadvisor/container_hints.json"      location of
94       the container hints file
95
96
97       --containerd="/run/containerd/containerd.sock"      containerd endpoint
98
99
100       --containerd-namespace="k8s.io"      containerd namespace
101
102
103       --context=""      The name of the kubeconfig context to use
104
105
106       --default-not-ready-toleration-seconds=300       Indicates  the tolera‐
107       tionSeconds of the toleration for notReady:NoExecute that is  added  by
108       default to every pod that does not already have such a toleration.
109
110
111       --default-unreachable-toleration-seconds=300      Indicates the tolera‐
112       tionSeconds of the toleration for unreachable:NoExecute that  is  added
113       by default to every pod that does not already have such a toleration.
114
115
116       --disable-root-cgroup-stats=false       Disable  collecting root Cgroup
117       stats
118
119
120       --docker="unix:///var/run/docker.sock"      docker endpoint
121
122
123       --docker-env-metadata-whitelist=""      a comma-separated list of envi‐
124       ronment  variable  keys  matched with specified prefix that needs to be
125       collected for docker containers
126
127
128       --docker-only=false      Only report docker containers in  addition  to
129       root stats
130
131
132       --docker-root="/var/lib/docker"       DEPRECATED:  docker  root is read
133       from docker info (this is a fallback, default: /var/lib/docker)
134
135
136       --docker-tls=false      use TLS to connect to docker
137
138
139       --docker-tls-ca="ca.pem"      path to trusted CA
140
141
142       --docker-tls-cert="cert.pem"      path to client certificate
143
144
145       --docker-tls-key="key.pem"      path to private key
146
147
148       --enable-load-reader=false      Whether to enable cpu load reader
149
150
151       --event-storage-age-limit="default=0"      Max length of time for which
152       to store events (per type). Value is a comma separated list of key val‐
153       ues, where the keys are event types (e.g.: creation, oom) or  "default"
154       and  the  value  is a duration. Default is applied to all non-specified
155       event types
156
157
158       --event-storage-event-limit="default=0"      Max number  of  events  to
159       store  (per type). Value is a comma separated list of key values, where
160       the keys are event types (e.g.: creation, oom)  or  "default"  and  the
161       value  is  an  integer.  Default  is applied to all non-specified event
162       types
163
164
165       --global-housekeeping-interval=1m0s      Interval between global house‐
166       keepings
167
168
169       --housekeeping-interval=10s       Interval between container housekeep‐
170       ings
171
172
173       --insecure-skip-tls-verify=false      If true, the server's certificate
174       will not be checked for validity. This will make your HTTPS connections
175       insecure
176
177
178       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
179       quests.
180
181
182       --log-backtrace-at=:0       when logging hits line file:N, emit a stack
183       trace
184
185
186       --log-cadvisor-usage=false      Whether to log the usage of the  cAdvi‐
187       sor container
188
189
190       --log-dir=""      If non-empty, write log files in this directory
191
192
193       --log-file=""      If non-empty, use this log file
194
195
196       --log-file-max-size=1800       Defines  the maximum size a log file can
197       grow to. Unit is megabytes. If the value is 0, the maximum file size is
198       unlimited.
199
200
201       --log-flush-frequency=5s       Maximum  number  of  seconds between log
202       flushes
203
204
205       --logtostderr=true      log to standard error instead of files
206
207
208       --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
209            Comma-separated  list  of  files  to check for machine-id. Use the
210       first one that exists.
211
212
213       --match-server-version=false       Require  server  version  to   match
214       client version
215
216
217       -n,  --namespace=""       If  present, the namespace scope for this CLI
218       request
219
220
221       --one-output=false      If true, only write logs to their native sever‐
222       ity level (vs also writing to each lower severity level
223
224
225       --password=""      Password for basic authentication to the API server
226
227
228       --profile="none"         Name   of   profile   to   capture.   One   of
229       (none|cpu|heap|goroutine|threadcreate|block|mutex)
230
231
232       --profile-output="profile.pprof"      Name of the  file  to  write  the
233       profile to
234
235
236       --referenced-reset-interval=0       Reset interval for referenced bytes
237       (container_referenced_bytes metric), number of measurement cycles after
238       which  referenced  bytes  are cleared, if set to 0 referenced bytes are
239       never cleared (default: 0)
240
241
242       --request-timeout="0"      The length of time to wait before giving  up
243       on  a  single  server  request. Non-zero values should contain a corre‐
244       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
245       out requests.
246
247
248       -s, --server=""      The address and port of the Kubernetes API server
249
250
251       --skip-headers=false       If  true,  avoid  header prefixes in the log
252       messages
253
254
255       --skip-log-headers=false      If true, avoid headers when  opening  log
256       files
257
258
259       --stderrthreshold=2      logs at or above this threshold go to stderr
260
261
262       --storage-driver-buffer-duration=1m0s      Writes in the storage driver
263       will be buffered for this duration, and committed  to  the  non  memory
264       backends as a single transaction
265
266
267       --storage-driver-db="cadvisor"      database name
268
269
270       --storage-driver-host="localhost:8086"      database host:port
271
272
273       --storage-driver-password="root"      database password
274
275
276       --storage-driver-secure=false      use secure connection with database
277
278
279       --storage-driver-table="stats"      table name
280
281
282       --storage-driver-user="root"      database username
283
284
285       --tls-server-name=""       Server  name  to  use for server certificate
286       validation. If it is not provided, the hostname  used  to  contact  the
287       server is used
288
289
290       --token=""      Bearer token for authentication to the API server
291
292
293       --update-machine-info-interval=5m0s       Interval between machine info
294       updates.
295
296
297       --user=""      The name of the kubeconfig user to use
298
299
300       --username=""      Username for basic authentication to the API server
301
302
303       -v, --v=0      number for the log level verbosity
304
305
306       --version=false      Print version information and quit
307
308
309       --vmodule=       comma-separated  list  of   pattern=N   settings   for
310       file-filtered logging
311
312
313       --warnings-as-errors=false      Treat warnings received from the server
314       as errors and exit with a non-zero exit code
315
316
317

EXAMPLE

319                # Get output from running pod mypod, using the first container by default
320                kubectl attach mypod
321
322                # Get output from ruby-container from pod mypod
323                kubectl attach mypod -c ruby-container
324
325                # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod mypod
326                # and sends stdout/stderr from 'bash' back to the client
327                kubectl attach mypod -c ruby-container -i -t
328
329                # Get output from the first pod of a ReplicaSet named nginx
330                kubectl attach rs/nginx
331
332
333
334

SEE ALSO

336       kubectl(1),
337
338
339

HISTORY

341       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
342       com)  based  on the kubernetes source material, but hopefully they have
343       been automatically generated since!
344
345
346
347Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum