1KUBERNETES(1) Jan 2015 KUBERNETES(1)
2
3
4
6 kubectl exec - Execute a command in a container
7
8
9
11 kubectl exec [OPTIONS]
12
13
14
16 Execute a command in a container.
17
18
19
21 -c, --container=""
22 Container name. If omitted, the first container in the pod will be
23 chosen
24
25
26 -p, --pod=""
27 Pod name
28
29
30 -i, --stdin=false
31 Pass stdin to the container
32
33
34 -t, --tty=false
35 Stdin is a TTY
36
37
38
40 --alsologtostderr=false
41 log to standard error as well as files
42
43
44 --application-metrics-count-limit=100
45 Max number of application metrics to store (per container)
46
47
48 --as=""
49 Username to impersonate for the operation
50
51
52 --as-group=[]
53 Group to impersonate for the operation, this flag can be repeated
54 to specify multiple groups.
55
56
57 --azure-container-registry-config=""
58 Path to the file containing Azure container registry configuration
59 information.
60
61
62 --boot-id-file="/proc/sys/kernel/random/boot_id"
63 Comma-separated list of files to check for boot-id. Use the first
64 one that exists.
65
66
67 --cache-dir="/builddir/.kube/http-cache"
68 Default HTTP cache directory
69
70
71 --certificate-authority=""
72 Path to a cert file for the certificate authority
73
74
75 --client-certificate=""
76 Path to a client certificate file for TLS
77
78
79 --client-key=""
80 Path to a client key file for TLS
81
82
83 --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
84 CIDRs opened in GCE firewall for LB traffic proxy health checks
85
86
87 --cluster=""
88 The name of the kubeconfig cluster to use
89
90
91 --container-hints="/etc/cadvisor/container_hints.json"
92 location of the container hints file
93
94
95 --containerd="unix:///var/run/containerd.sock"
96 containerd endpoint
97
98
99 --context=""
100 The name of the kubeconfig context to use
101
102
103 --default-not-ready-toleration-seconds=300
104 Indicates the tolerationSeconds of the toleration for
105 notReady:NoExecute that is added by default to every pod that does not
106 already have such a toleration.
107
108
109 --default-unreachable-toleration-seconds=300
110 Indicates the tolerationSeconds of the toleration for unreach‐
111 able:NoExecute that is added by default to every pod that does not
112 already have such a toleration.
113
114
115 --docker="unix:///var/run/docker.sock"
116 docker endpoint
117
118
119 --docker-env-metadata-whitelist=""
120 a comma-separated list of environment variable keys that needs to
121 be collected for docker containers
122
123
124 --docker-only=false
125 Only report docker containers in addition to root stats
126
127
128 --docker-root="/var/lib/docker"
129 DEPRECATED: docker root is read from docker info (this is a fall‐
130 back, default: /var/lib/docker)
131
132
133 --docker-tls=false
134 use TLS to connect to docker
135
136
137 --docker-tls-ca="ca.pem"
138 path to trusted CA
139
140
141 --docker-tls-cert="cert.pem"
142 path to client certificate
143
144
145 --docker-tls-key="key.pem"
146 path to private key
147
148
149 --enable-load-reader=false
150 Whether to enable cpu load reader
151
152
153 --event-storage-age-limit="default=0"
154 Max length of time for which to store events (per type). Value is a
155 comma separated list of key values, where the keys are event types
156 (e.g.: creation, oom) or "default" and the value is a duration. Default
157 is applied to all non-specified event types
158
159
160 --event-storage-event-limit="default=0"
161 Max number of events to store (per type). Value is a comma sepa‐
162 rated list of key values, where the keys are event types (e.g.: cre‐
163 ation, oom) or "default" and the value is an integer. Default is
164 applied to all non-specified event types
165
166
167 --global-housekeeping-interval=1m0s
168 Interval between global housekeepings
169
170
171 --housekeeping-interval=10s
172 Interval between container housekeepings
173
174
175 --insecure-skip-tls-verify=false
176 If true, the server's certificate will not be checked for validity.
177 This will make your HTTPS connections insecure
178
179
180 --kubeconfig=""
181 Path to the kubeconfig file to use for CLI requests.
182
183
184 --log-backtrace-at=:0
185 when logging hits line file:N, emit a stack trace
186
187
188 --log-cadvisor-usage=false
189 Whether to log the usage of the cAdvisor container
190
191
192 --log-dir=""
193 If non-empty, write log files in this directory
194
195
196 --log-file=""
197 If non-empty, use this log file
198
199
200 --log-flush-frequency=5s
201 Maximum number of seconds between log flushes
202
203
204 --logtostderr=true
205 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
214 Require server version to match client version
215
216
217 --mesos-agent="127.0.0.1:5051"
218 Mesos agent address
219
220
221 --mesos-agent-timeout=10s
222 Mesos agent timeout
223
224
225 -n, --namespace=""
226 If present, the namespace scope for this CLI request
227
228
229 --password=""
230 Password for basic authentication to the API server
231
232
233 --profile="none"
234 Name of profile to capture. One of (none|cpu|heap|goroutine|thread‐
235 create|block|mutex)
236
237
238 --profile-output="profile.pprof"
239 Name of the file to write the profile to
240
241
242 --request-timeout="0"
243 The length of time to wait before giving up on a single server
244 request. Non-zero values should contain a corresponding time unit (e.g.
245 1s, 2m, 3h). A value of zero means don't timeout requests.
246
247
248 -s, --server=""
249 The address and port of the Kubernetes API server
250
251
252 --skip-headers=false
253 If true, avoid header prefixes in the log messages
254
255
256 --stderrthreshold=2
257 logs at or above this threshold go to stderr
258
259
260 --storage-driver-buffer-duration=1m0s
261 Writes in the storage driver will be buffered for this duration,
262 and committed to the non memory backends as a single transaction
263
264
265 --storage-driver-db="cadvisor"
266 database name
267
268
269 --storage-driver-host="localhost:8086"
270 database host:port
271
272
273 --storage-driver-password="root"
274 database password
275
276
277 --storage-driver-secure=false
278 use secure connection with database
279
280
281 --storage-driver-table="stats"
282 table name
283
284
285 --storage-driver-user="root"
286 database username
287
288
289 --token=""
290 Bearer token for authentication to the API server
291
292
293 --user=""
294 The name of the kubeconfig user to use
295
296
297 --username=""
298 Username for basic authentication to the API server
299
300
301 -v, --v=0
302 log level for V logs
303
304
305 --version=false
306 Print version information and quit
307
308
309 --vmodule=
310 comma-separated list of pattern=N settings for file-filtered log‐
311 ging
312
313
314
316 # Get output from running 'date' from pod 123456-7890, using the first container by default
317 kubectl exec 123456-7890 date
318
319 # Get output from running 'date' in ruby-container from pod 123456-7890
320 kubectl exec 123456-7890 -c ruby-container date
321
322 # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890
323 # and sends stdout/stderr from 'bash' back to the client
324 kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il
325
326 # List contents of /usr from the first container of pod 123456-7890 and sort by modification time.
327 # If the command you want to execute in the pod has any flags in common (e.g. -i),
328 # you must use two dashes (--) to separate your command's flags/arguments.
329 # Also note, do not surround your command and its flags/arguments with quotes
330 # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr").
331 kubectl exec 123456-7890 -i -t -- ls -t /usr
332
333
334
335
337 kubectl(1),
338
339
340
342 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
343 com) based on the kubernetes source material, but hopefully they have
344 been automatically generated since!
345
346
347
348Eric Paris kubernetes User Manuals KUBERNETES(1)