1KUBERNETES(1) Jan 2015 KUBERNETES(1)
2
3
4
6 kubectl run - Run a particular image on the cluster
7
8
9
11 kubectl run [OPTIONS]
12
13
14
16 Create and run a particular image, possibly replicated.
17
18
19 Creates a deployment or job to manage the created container(s).
20
21
22
24 --allow-missing-template-keys=true
25 If true, ignore any errors in templates when a field or map key is
26 missing in the template. Only applies to golang and jsonpath output
27 formats.
28
29
30 --attach=false
31 If true, wait for the Pod to start running, and then attach to the
32 Pod as if 'kubectl attach ...' were called. Default false, unless
33 '-i/--stdin' is set, in which case the default is true. With
34 '--restart=Never' the exit code of the container process is returned.
35
36
37 --cascade=true
38 If true, cascade the deletion of the resources managed by this
39 resource (e.g. Pods created by a ReplicationController). Default true.
40
41
42 --command=false
43 If true and extra arguments are present, use them as the 'command'
44 field in the container, rather than the 'args' field which is the
45 default.
46
47
48 --dry-run=false
49 If true, only print the object that would be sent, without sending
50 it.
51
52
53 --env=[]
54 Environment variables to set in the container
55
56
57 --expose=false
58 If true, a public, external service is created for the container(s)
59 which are run
60
61
62 -f, --filename=[]
63 to use to replace the resource.
64
65
66 --force=false
67 Only used when grace-period=0. If true, immediately remove
68 resources from API and bypass graceful deletion. Note that immediate
69 deletion of some resources may result in inconsistency or data loss and
70 requires confirmation.
71
72
73 --generator=""
74 The name of the API generator to use, see ⟨http://kuber‐
75 netes.io/docs/user-guide/kubectl-conventions/#generators⟩ for a list.
76
77
78 --grace-period=-1
79 Period of time in seconds given to the resource to terminate grace‐
80 fully. Ignored if negative. Set to 1 for immediate shutdown. Can only
81 be set to 0 when --force is true (force deletion).
82
83
84 --hostport=-1
85 The host port mapping for the container port. To demonstrate a sin‐
86 gle-machine container.
87
88
89 --image=""
90 The image for the container to run.
91
92
93 --image-pull-policy=""
94 The image pull policy for the container. If left empty, this value
95 will not be specified by the client and defaulted by the server
96
97
98 -k, --kustomize=""
99 Process a kustomization directory. This flag can't be used together
100 with -f or -R.
101
102
103 -l, --labels=""
104 Comma separated labels to apply to the pod(s). Will override previ‐
105 ous values.
106
107
108 --leave-stdin-open=false
109 If the pod is started in interactive mode or with stdin, leave
110 stdin open after the first attach completes. By default, stdin will be
111 closed after the first attach completes.
112
113
114 --limits=""
115 The resource requirement limits for this container. For example,
116 'cpu=200m,memory=512Mi'. Note that server side components may assign
117 limits depending on the server configuration, such as limit ranges.
118
119
120 -o, --output=""
121 Output format. One of: json|yaml|name|go-template|go-tem‐
122 plate-file|template|templatefile|jsonpath|jsonpath-file.
123
124
125 --overrides=""
126 An inline JSON override for the generated object. If this is
127 non-empty, it is used to override the generated object. Requires that
128 the object supply a valid apiVersion field.
129
130
131 --pod-running-timeout=1m0s
132 The length of time (like 5s, 2m, or 3h, higher than zero) to wait
133 until at least one pod is running
134
135
136 --port=""
137 The port that this container exposes. If --expose is true, this is
138 also the port used by the service that is created.
139
140
141 --quiet=false
142 If true, suppress prompt messages.
143
144
145 --record=false
146 Record current kubectl command in the resource annotation. If set
147 to false, do not record the command. If set to true, record the com‐
148 mand. If not set, default to updating the existing annotation value
149 only if one already exists.
150
151
152 -R, --recursive=false
153 Process the directory used in -f, --filename recursively. Useful
154 when you want to manage related manifests organized within the same
155 directory.
156
157
158 -r, --replicas=1
159 Number of replicas to create for this container. Default is 1.
160
161
162 --requests=""
163 The resource requirement requests for this container. For example,
164 'cpu=100m,memory=256Mi'. Note that server side components may assign
165 requests depending on the server configuration, such as limit ranges.
166
167
168 --restart="Always"
169 The restart policy for this Pod. Legal values [Always, OnFailure,
170 Never]. If set to 'Always' a deployment is created, if set to 'OnFail‐
171 ure' a job is created, if set to 'Never', a regular pod is created. For
172 the latter two --replicas must be 1. Default 'Always', for CronJobs
173 Never.
174
175
176 --rm=false
177 If true, delete resources created in this command for attached con‐
178 tainers.
179
180
181 --save-config=false
182 If true, the configuration of current object will be saved in its
183 annotation. Otherwise, the annotation will be unchanged. This flag is
184 useful when you want to perform kubectl apply on this object in the
185 future.
186
187
188 --schedule=""
189 A schedule in the Cron format the job should be run with.
190
191
192 --service-generator="service/v2"
193 The name of the generator to use for creating a service. Only used
194 if --expose is true
195
196
197 --service-overrides=""
198 An inline JSON override for the generated service object. If this
199 is non-empty, it is used to override the generated object. Requires
200 that the object supply a valid apiVersion field. Only used if --expose
201 is true.
202
203
204 --serviceaccount=""
205 Service account to set in the pod spec
206
207
208 -i, --stdin=false
209 Keep stdin open on the container(s) in the pod, even if nothing is
210 attached.
211
212
213 --template=""
214 Template string or path to template file to use when -o=go-tem‐
215 plate, -o=go-template-file. The template format is golang templates [
216 ⟨http://golang.org/pkg/text/template/#pkg-overview⟩].
217
218
219 --timeout=0s
220 The length of time to wait before giving up on a delete, zero means
221 determine a timeout from the size of the object
222
223
224 -t, --tty=false
225 Allocated a TTY for each container in the pod.
226
227
228 --wait=false
229 If true, wait for resources to be gone before returning. This waits
230 for finalizers.
231
232
233
235 --alsologtostderr=false
236 log to standard error as well as files
237
238
239 --application-metrics-count-limit=100
240 Max number of application metrics to store (per container)
241
242
243 --as=""
244 Username to impersonate for the operation
245
246
247 --as-group=[]
248 Group to impersonate for the operation, this flag can be repeated
249 to specify multiple groups.
250
251
252 --azure-container-registry-config=""
253 Path to the file containing Azure container registry configuration
254 information.
255
256
257 --boot-id-file="/proc/sys/kernel/random/boot_id"
258 Comma-separated list of files to check for boot-id. Use the first
259 one that exists.
260
261
262 --cache-dir="/builddir/.kube/http-cache"
263 Default HTTP cache directory
264
265
266 --certificate-authority=""
267 Path to a cert file for the certificate authority
268
269
270 --client-certificate=""
271 Path to a client certificate file for TLS
272
273
274 --client-key=""
275 Path to a client key file for TLS
276
277
278 --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
279 CIDRs opened in GCE firewall for LB traffic proxy health checks
280
281
282 --cluster=""
283 The name of the kubeconfig cluster to use
284
285
286 --container-hints="/etc/cadvisor/container_hints.json"
287 location of the container hints file
288
289
290 --containerd="/run/containerd/containerd.sock"
291 containerd endpoint
292
293
294 --containerd-namespace="k8s.io"
295 containerd namespace
296
297
298 --context=""
299 The name of the kubeconfig context to use
300
301
302 --default-not-ready-toleration-seconds=300
303 Indicates the tolerationSeconds of the toleration for
304 notReady:NoExecute that is added by default to every pod that does not
305 already have such a toleration.
306
307
308 --default-unreachable-toleration-seconds=300
309 Indicates the tolerationSeconds of the toleration for unreach‐
310 able:NoExecute that is added by default to every pod that does not
311 already have such a toleration.
312
313
314 --docker="unix:///var/run/docker.sock"
315 docker endpoint
316
317
318 --docker-env-metadata-whitelist=""
319 a comma-separated list of environment variable keys that needs to
320 be collected for docker containers
321
322
323 --docker-only=false
324 Only report docker containers in addition to root stats
325
326
327 --docker-root="/var/lib/docker"
328 DEPRECATED: docker root is read from docker info (this is a fall‐
329 back, default: /var/lib/docker)
330
331
332 --docker-tls=false
333 use TLS to connect to docker
334
335
336 --docker-tls-ca="ca.pem"
337 path to trusted CA
338
339
340 --docker-tls-cert="cert.pem"
341 path to client certificate
342
343
344 --docker-tls-key="key.pem"
345 path to private key
346
347
348 --enable-load-reader=false
349 Whether to enable cpu load reader
350
351
352 --event-storage-age-limit="default=0"
353 Max length of time for which to store events (per type). Value is a
354 comma separated list of key values, where the keys are event types
355 (e.g.: creation, oom) or "default" and the value is a duration. Default
356 is applied to all non-specified event types
357
358
359 --event-storage-event-limit="default=0"
360 Max number of events to store (per type). Value is a comma sepa‐
361 rated list of key values, where the keys are event types (e.g.: cre‐
362 ation, oom) or "default" and the value is an integer. Default is
363 applied to all non-specified event types
364
365
366 --global-housekeeping-interval=1m0s
367 Interval between global housekeepings
368
369
370 --housekeeping-interval=10s
371 Interval between container housekeepings
372
373
374 --insecure-skip-tls-verify=false
375 If true, the server's certificate will not be checked for validity.
376 This will make your HTTPS connections insecure
377
378
379 --kubeconfig=""
380 Path to the kubeconfig file to use for CLI requests.
381
382
383 --log-backtrace-at=:0
384 when logging hits line file:N, emit a stack trace
385
386
387 --log-cadvisor-usage=false
388 Whether to log the usage of the cAdvisor container
389
390
391 --log-dir=""
392 If non-empty, write log files in this directory
393
394
395 --log-file=""
396 If non-empty, use this log file
397
398
399 --log-file-max-size=1800
400 Defines the maximum size a log file can grow to. Unit is megabytes.
401 If the value is 0, the maximum file size is unlimited.
402
403
404 --log-flush-frequency=5s
405 Maximum number of seconds between log flushes
406
407
408 --logtostderr=true
409 log to standard error instead of files
410
411
412 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
413 Comma-separated list of files to check for machine-id. Use the
414 first one that exists.
415
416
417 --match-server-version=false
418 Require server version to match client version
419
420
421 -n, --namespace=""
422 If present, the namespace scope for this CLI request
423
424
425 --password=""
426 Password for basic authentication to the API server
427
428
429 --profile="none"
430 Name of profile to capture. One of (none|cpu|heap|goroutine|thread‐
431 create|block|mutex)
432
433
434 --profile-output="profile.pprof"
435 Name of the file to write the profile to
436
437
438 --request-timeout="0"
439 The length of time to wait before giving up on a single server
440 request. Non-zero values should contain a corresponding time unit (e.g.
441 1s, 2m, 3h). A value of zero means don't timeout requests.
442
443
444 -s, --server=""
445 The address and port of the Kubernetes API server
446
447
448 --skip-headers=false
449 If true, avoid header prefixes in the log messages
450
451
452 --skip-log-headers=false
453 If true, avoid headers when opening log files
454
455
456 --stderrthreshold=2
457 logs at or above this threshold go to stderr
458
459
460 --storage-driver-buffer-duration=1m0s
461 Writes in the storage driver will be buffered for this duration,
462 and committed to the non memory backends as a single transaction
463
464
465 --storage-driver-db="cadvisor"
466 database name
467
468
469 --storage-driver-host="localhost:8086"
470 database host:port
471
472
473 --storage-driver-password="root"
474 database password
475
476
477 --storage-driver-secure=false
478 use secure connection with database
479
480
481 --storage-driver-table="stats"
482 table name
483
484
485 --storage-driver-user="root"
486 database username
487
488
489 --token=""
490 Bearer token for authentication to the API server
491
492
493 --update-machine-info-interval=5m0s
494 Interval between machine info updates.
495
496
497 --user=""
498 The name of the kubeconfig user to use
499
500
501 --username=""
502 Username for basic authentication to the API server
503
504
505 -v, --v=0
506 number for the log level verbosity
507
508
509 --version=false
510 Print version information and quit
511
512
513 --vmodule=
514 comma-separated list of pattern=N settings for file-filtered log‐
515 ging
516
517
518
520 # Start a single instance of nginx.
521 kubectl run nginx --image=nginx
522
523 # Start a single instance of hazelcast and let the container expose port 5701 .
524 kubectl run hazelcast --image=hazelcast --port=5701
525
526 # Start a single instance of hazelcast and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container.
527 kubectl run hazelcast --image=hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
528
529 # Start a single instance of hazelcast and set labels "app=hazelcast" and "env=prod" in the container.
530 kubectl run hazelcast --image=hazelcast --labels="app=hazelcast,env=prod"
531
532 # Start a replicated instance of nginx.
533 kubectl run nginx --image=nginx --replicas=5
534
535 # Dry run. Print the corresponding API objects without creating them.
536 kubectl run nginx --image=nginx --dry-run
537
538 # Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON.
539 kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'
540
541 # Start a pod of busybox and keep it in the foreground, don't restart it if it exits.
542 kubectl run -i -t busybox --image=busybox --restart=Never
543
544 # Start the nginx container using the default command, but use custom arguments (arg1 .. argN) for that command.
545 kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
546
547 # Start the nginx container using a different command and custom arguments.
548 kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
549
550 # Start the perl container to compute π to 2000 places and print it out.
551 kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
552
553 # Start the cron job to compute π to 2000 places and print it out every 5 minutes.
554 kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
555
556
557
558
560 kubectl(1),
561
562
563
565 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
566 com) based on the kubernetes source material, but hopefully they have
567 been automatically generated since!
568
569
570
571Eric Paris kubernetes User Manuals KUBERNETES(1)