1KUBERNETES(1)                      Jan 2015                      KUBERNETES(1)
2
3
4

NAME

6       kubectl exec - Execute a command in a container
7
8
9

SYNOPSIS

11       kubectl exec [OPTIONS]
12
13
14

DESCRIPTION

16       Execute a command in a container.
17
18
19

OPTIONS

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

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

326                # Get output from running 'date' command from pod mypod, using the first container by default
327                kubectl exec mypod date
328
329                # Get output from running 'date' command in ruby-container from pod mypod
330                kubectl exec mypod -c ruby-container date
331
332                # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod mypod
333                # and sends stdout/stderr from 'bash' back to the client
334                kubectl exec mypod -c ruby-container -i -t -- bash -il
335
336                # List contents of /usr from the first container of pod mypod and sort by modification time.
337                # If the command you want to execute in the pod has any flags in common (e.g. -i),
338                # you must use two dashes (--) to separate your command's flags/arguments.
339                # Also note, do not surround your command and its flags/arguments with quotes
340                # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr").
341                kubectl exec mypod -i -t -- ls -t /usr
342
343                # Get output from running 'date' command from the first pod of the deployment mydeployment, using the first container by default
344                kubectl exec deploy/mydeployment date
345
346                # Get output from running 'date' command from the first pod of the service myservice, using the first container by default
347                kubectl exec svc/myservice date
348
349
350
351

SEE ALSO

353       kubectl(1),
354
355
356

HISTORY

358       January  2015,  Originally compiled by Eric Paris (eparis at redhat dot
359       com) based on the kubernetes source material, but hopefully  they  have
360       been automatically generated since!
361
362
363
364Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum