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 --allow-verification-with-non-compliant-keys=false
41 Allow a SignatureVerifier to use keys which are technically
42 non-compliant with RFC6962.
43
44
45 --alsologtostderr=false
46 log to standard error as well as files
47
48
49 --application-metrics-count-limit=100
50 Max number of application metrics to store (per container)
51
52
53 --as=""
54 Username to impersonate for the operation
55
56
57 --as-group=[]
58 Group to impersonate for the operation, this flag can be repeated
59 to specify multiple groups.
60
61
62 --azure-container-registry-config=""
63 Path to the file containing Azure container registry configuration
64 information.
65
66
67 --boot-id-file="/proc/sys/kernel/random/boot_id"
68 Comma-separated list of files to check for boot-id. Use the first
69 one that exists.
70
71
72 --cache-dir="/builddir/.kube/http-cache"
73 Default HTTP cache directory
74
75
76 --certificate-authority=""
77 Path to a cert file for the certificate authority
78
79
80 --client-certificate=""
81 Path to a client certificate file for TLS
82
83
84 --client-key=""
85 Path to a client key file for TLS
86
87
88 --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
89 CIDRs opened in GCE firewall for LB traffic proxy health checks
90
91
92 --cluster=""
93 The name of the kubeconfig cluster to use
94
95
96 --container-hints="/etc/cadvisor/container_hints.json"
97 location of the container hints file
98
99
100 --containerd="unix:///var/run/containerd.sock"
101 containerd endpoint
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 --google-json-key=""
177 The Google Cloud Platform Service Account JSON Key to use for
178 authentication.
179
180
181 --housekeeping-interval=10s
182 Interval between container housekeepings
183
184
185 --insecure-skip-tls-verify=false
186 If true, the server's certificate will not be checked for validity.
187 This will make your HTTPS connections insecure
188
189
190 --kubeconfig=""
191 Path to the kubeconfig file to use for CLI requests.
192
193
194 --log-backtrace-at=:0
195 when logging hits line file:N, emit a stack trace
196
197
198 --log-cadvisor-usage=false
199 Whether to log the usage of the cAdvisor container
200
201
202 --log-dir=""
203 If non-empty, write log files in this directory
204
205
206 --log-flush-frequency=5s
207 Maximum number of seconds between log flushes
208
209
210 --logtostderr=true
211 log to standard error instead of files
212
213
214 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
215 Comma-separated list of files to check for machine-id. Use the
216 first one that exists.
217
218
219 --match-server-version=false
220 Require server version to match client version
221
222
223 --mesos-agent="127.0.0.1:5051"
224 Mesos agent address
225
226
227 --mesos-agent-timeout=10s
228 Mesos agent timeout
229
230
231 -n, --namespace=""
232 If present, the namespace scope for this CLI request
233
234
235 --request-timeout="0"
236 The length of time to wait before giving up on a single server
237 request. Non-zero values should contain a corresponding time unit (e.g.
238 1s, 2m, 3h). A value of zero means don't timeout requests.
239
240
241 -s, --server=""
242 The address and port of the Kubernetes API server
243
244
245 --stderrthreshold=2
246 logs at or above this threshold go to stderr
247
248
249 --storage-driver-buffer-duration=1m0s
250 Writes in the storage driver will be buffered for this duration,
251 and committed to the non memory backends as a single transaction
252
253
254 --storage-driver-db="cadvisor"
255 database name
256
257
258 --storage-driver-host="localhost:8086"
259 database host:port
260
261
262 --storage-driver-password="root"
263 database password
264
265
266 --storage-driver-secure=false
267 use secure connection with database
268
269
270 --storage-driver-table="stats"
271 table name
272
273
274 --storage-driver-user="root"
275 database username
276
277
278 --token=""
279 Bearer token for authentication to the API server
280
281
282 --user=""
283 The name of the kubeconfig user to use
284
285
286 -v, --v=0
287 log level for V logs
288
289
290 --version=false
291 Print version information and quit
292
293
294 --vmodule=
295 comma-separated list of pattern=N settings for file-filtered log‐
296 ging
297
298
299
301 # Get output from running 'date' from pod 123456-7890, using the first container by default
302 kubectl exec 123456-7890 date
303
304 # Get output from running 'date' in ruby-container from pod 123456-7890
305 kubectl exec 123456-7890 -c ruby-container date
306
307 # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890
308 # and sends stdout/stderr from 'bash' back to the client
309 kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il
310
311 # List contents of /usr from the first container of pod 123456-7890 and sort by modification time.
312 # If the command you want to execute in the pod has any flags in common (e.g. -i),
313 # you must use two dashes (--) to separate your command's flags/arguments.
314 # Also note, do not surround your command and its flags/arguments with quotes
315 # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr").
316 kubectl exec 123456-7890 -i -t -- ls -t /usr
317
318
319
320
322 kubectl(1),
323
324
325
327 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
328 com) based on the kubernetes source material, but hopefully they have
329 been automatically generated since!
330
331
332
333Eric Paris kubernetes User Manuals KUBERNETES(1)