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       -f, --filename=[]
27           to use to exec into the resource
28
29
30       --pod-running-timeout=1m0s
31           The length of time (like 5s, 2m, or 3h, higher than zero) to wait
32       until at least one pod is running
33
34
35       -i, --stdin=false
36           Pass stdin to the container
37
38
39       -t, --tty=false
40           Stdin is a TTY
41
42
43

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

347                # Get output from running 'date' command from pod mypod, using the first container by default
348                kubectl exec mypod -- date
349
350                # Get output from running 'date' command in ruby-container from pod mypod
351                kubectl exec mypod -c ruby-container -- date
352
353                # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod mypod
354                # and sends stdout/stderr from 'bash' back to the client
355                kubectl exec mypod -c ruby-container -i -t -- bash -il
356
357                # List contents of /usr from the first container of pod mypod and sort by modification time.
358                # If the command you want to execute in the pod has any flags in common (e.g. -i),
359                # you must use two dashes (--) to separate your command's flags/arguments.
360                # Also note, do not surround your command and its flags/arguments with quotes
361                # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr").
362                kubectl exec mypod -i -t -- ls -t /usr
363
364                # Get output from running 'date' command from the first pod of the deployment mydeployment, using the first container by default
365                kubectl exec deploy/mydeployment -- date
366
367                # Get output from running 'date' command from the first pod of the service myservice, using the first container by default
368                kubectl exec svc/myservice -- date
369
370
371
372

SEE ALSO

374       kubectl(1),
375
376
377

HISTORY

379       January 2015, Originally compiled by Eric Paris (eparis at redhat dot
380       com) based on the kubernetes source material, but hopefully they have
381       been automatically generated since!
382
383
384
385Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum