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