1KUBERNETES(1)                      Jan 2015                      KUBERNETES(1)
2
3
4

NAME

6       kubectl apply - Apply a configuration to a resource by filename or
7       stdin
8
9
10

SYNOPSIS

12       kubectl apply [OPTIONS]
13
14
15

DESCRIPTION

17       Apply a configuration to a resource by filename or stdin. The resource
18       name must be specified. This resource will be created if it doesn't
19       exist yet. To use 'apply', always create the resource initially with
20       either 'apply' or 'create --save-config'.
21
22
23       JSON and YAML formats are accepted.
24
25
26       Alpha Disclaimer: the --prune functionality is not yet complete. Do not
27       use unless you are aware of what the current state is. See
28https://issues.k8s.io/34274⟩.
29
30
31

OPTIONS

33       --all=false
34           Select all resources in the namespace of the specified resource
35       types.
36
37
38       --allow-missing-template-keys=true
39           If true, ignore any errors in templates when a field or map key is
40       missing in the template. Only applies to golang and jsonpath output
41       formats.
42
43
44       --cascade=true
45           If true, cascade the deletion of the resources managed by this
46       resource (e.g. Pods created by a ReplicationController).  Default true.
47
48
49       --dry-run="none"
50           Must be "none", "server", or "client". If client strategy, only
51       print the object that would be sent, without sending it. If server
52       strategy, submit server-side request without persisting the resource.
53
54
55       --field-manager="kubectl"
56           Name of the manager used to track field ownership.
57
58
59       -f, --filename=[]
60           that contains the configuration to apply
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       --force-conflicts=false
70           If true, server-side apply will force the changes against
71       conflicts.
72
73
74       --grace-period=-1
75           Period of time in seconds given to the resource to terminate
76       gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can
77       only be set to 0 when --force is true (force deletion).
78
79
80       -k, --kustomize=""
81           Process a kustomization directory. This flag can't be used together
82       with -f or -R.
83
84
85       --openapi-patch=true
86           If true, use openapi to calculate diff when the openapi presents
87       and the resource can be found in the openapi spec. Otherwise, fall back
88       to use baked-in types.
89
90
91       -o, --output=""
92           Output format. One of:
93       json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
94
95
96       --overwrite=true
97           Automatically resolve conflicts between the modified and live
98       configuration by using values from the modified configuration
99
100
101       --prune=false
102           Automatically delete resource objects, including the uninitialized
103       ones, that do not appear in the configs and are created by either apply
104       or create --save-config. Should be used with either -l or --all.
105
106
107       --prune-whitelist=[]
108           Overwrite the default whitelist with <group/version/kind> for
109       --prune
110
111
112       --record=false
113           Record current kubectl command in the resource annotation. If set
114       to false, do not record the command. If set to true, record the
115       command. If not set, default to updating the existing annotation value
116       only if one already exists.
117
118
119       -R, --recursive=false
120           Process the directory used in -f, --filename recursively. Useful
121       when you want to manage related manifests organized within the same
122       directory.
123
124
125       -l, --selector=""
126           Selector (label query) to filter on, supports '=', '==', and
127       '!='.(e.g. -l key1=value1,key2=value2)
128
129
130       --server-dry-run=false
131           If true, request will be sent to server with dry-run flag, which
132       means the modifications won't be persisted.
133
134
135       --server-side=false
136           If true, apply runs in the server instead of the client.
137
138
139       --template=""
140           Template string or path to template file to use when
141       -o=go-template, -o=go-template-file. The template format is golang
142       templates [ ⟨http://golang.org/pkg/text/template/#pkg-overview⟩].
143
144
145       --timeout=0s
146           The length of time to wait before giving up on a delete, zero means
147       determine a timeout from the size of the object
148
149
150       --validate=true
151           If true, use a schema to validate the input before sending it
152
153
154       --wait=false
155           If true, wait for resources to be gone before returning. This waits
156       for finalizers.
157
158
159

OPTIONS INHERITED FROM PARENT COMMANDS

161       --add-dir-header=false
162           If true, adds the file directory to the header
163
164
165       --alsologtostderr=false
166           log to standard error as well as files
167
168
169       --application-metrics-count-limit=100
170           Max number of application metrics to store (per container)
171
172
173       --as=""
174           Username to impersonate for the operation
175
176
177       --as-group=[]
178           Group to impersonate for the operation, this flag can be repeated
179       to specify multiple groups.
180
181
182       --azure-container-registry-config=""
183           Path to the file containing Azure container registry configuration
184       information.
185
186
187       --boot-id-file="/proc/sys/kernel/random/boot_id"
188           Comma-separated list of files to check for boot-id. Use the first
189       one that exists.
190
191
192       --cache-dir="/builddir/.kube/http-cache"
193           Default HTTP cache directory
194
195
196       --certificate-authority=""
197           Path to a cert file for the certificate authority
198
199
200       --client-certificate=""
201           Path to a client certificate file for TLS
202
203
204       --client-key=""
205           Path to a client key file for TLS
206
207
208       --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
209           CIDRs opened in GCE firewall for L7 LB traffic proxy  health checks
210
211
212       --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
213           CIDRs opened in GCE firewall for L4 LB traffic proxy  health checks
214
215
216       --cluster=""
217           The name of the kubeconfig cluster to use
218
219
220       --container-hints="/etc/cadvisor/container_hints.json"
221           location of the container hints file
222
223
224       --containerd="/run/containerd/containerd.sock"
225           containerd endpoint
226
227
228       --containerd-namespace="k8s.io"
229           containerd namespace
230
231
232       --context=""
233           The name of the kubeconfig context to use
234
235
236       --default-not-ready-toleration-seconds=300
237           Indicates the tolerationSeconds of the toleration for
238       notReady:NoExecute that is added by default to every pod that does not
239       already have such a toleration.
240
241
242       --default-unreachable-toleration-seconds=300
243           Indicates the tolerationSeconds of the toleration for
244       unreachable:NoExecute that is added by default to every pod that does
245       not already have such a toleration.
246
247
248       --disable-root-cgroup-stats=false
249           Disable collecting root Cgroup stats
250
251
252       --docker="unix:///var/run/docker.sock"
253           docker endpoint
254
255
256       --docker-env-metadata-whitelist=""
257           a comma-separated list of environment variable keys that needs to
258       be collected for docker containers
259
260
261       --docker-only=false
262           Only report docker containers in addition to root stats
263
264
265       --docker-root="/var/lib/docker"
266           DEPRECATED: docker root is read from docker info (this is a
267       fallback, default: /var/lib/docker)
268
269
270       --docker-tls=false
271           use TLS to connect to docker
272
273
274       --docker-tls-ca="ca.pem"
275           path to trusted CA
276
277
278       --docker-tls-cert="cert.pem"
279           path to client certificate
280
281
282       --docker-tls-key="key.pem"
283           path to private key
284
285
286       --enable-load-reader=false
287           Whether to enable cpu load reader
288
289
290       --event-storage-age-limit="default=0"
291           Max length of time for which to store events (per type). Value is a
292       comma separated list of key values, where the keys are event types
293       (e.g.: creation, oom) or "default" and the value is a duration. Default
294       is applied to all non-specified event types
295
296
297       --event-storage-event-limit="default=0"
298           Max number of events to store (per type). Value is a comma
299       separated list of key values, where the keys are event types (e.g.:
300       creation, oom) or "default" and the value is an integer. Default is
301       applied to all non-specified event types
302
303
304       --global-housekeeping-interval=1m0s
305           Interval between global housekeepings
306
307
308       --housekeeping-interval=10s
309           Interval between container housekeepings
310
311
312       --insecure-skip-tls-verify=false
313           If true, the server's certificate will not be checked for validity.
314       This will make your HTTPS connections insecure
315
316
317       --kubeconfig=""
318           Path to the kubeconfig file to use for CLI requests.
319
320
321       --log-backtrace-at=:0
322           when logging hits line file:N, emit a stack trace
323
324
325       --log-cadvisor-usage=false
326           Whether to log the usage of the cAdvisor container
327
328
329       --log-dir=""
330           If non-empty, write log files in this directory
331
332
333       --log-file=""
334           If non-empty, use this log file
335
336
337       --log-file-max-size=1800
338           Defines the maximum size a log file can grow to. Unit is megabytes.
339       If the value is 0, the maximum file size is unlimited.
340
341
342       --log-flush-frequency=5s
343           Maximum number of seconds between log flushes
344
345
346       --logtostderr=true
347           log to standard error instead of files
348
349
350       --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
351           Comma-separated list of files to check for machine-id. Use the
352       first one that exists.
353
354
355       --match-server-version=false
356           Require server version to match client version
357
358
359       -n, --namespace=""
360           If present, the namespace scope for this CLI request
361
362
363       --password=""
364           Password for basic authentication to the API server
365
366
367       --profile="none"
368           Name of profile to capture. One of
369       (none|cpu|heap|goroutine|threadcreate|block|mutex)
370
371
372       --profile-output="profile.pprof"
373           Name of the file to write the profile to
374
375
376       --request-timeout="0"
377           The length of time to wait before giving up on a single server
378       request. Non-zero values should contain a corresponding time unit (e.g.
379       1s, 2m, 3h). A value of zero means don't timeout requests.
380
381
382       -s, --server=""
383           The address and port of the Kubernetes API server
384
385
386       --skip-headers=false
387           If true, avoid header prefixes in the log messages
388
389
390       --skip-log-headers=false
391           If true, avoid headers when opening log files
392
393
394       --stderrthreshold=2
395           logs at or above this threshold go to stderr
396
397
398       --storage-driver-buffer-duration=1m0s
399           Writes in the storage driver will be buffered for this duration,
400       and committed to the non memory backends as a single transaction
401
402
403       --storage-driver-db="cadvisor"
404           database name
405
406
407       --storage-driver-host="localhost:8086"
408           database host:port
409
410
411       --storage-driver-password="root"
412           database password
413
414
415       --storage-driver-secure=false
416           use secure connection with database
417
418
419       --storage-driver-table="stats"
420           table name
421
422
423       --storage-driver-user="root"
424           database username
425
426
427       --tls-server-name=""
428           Server name to use for server certificate validation. If it is not
429       provided, the hostname used to contact the server is used
430
431
432       --token=""
433           Bearer token for authentication to the API server
434
435
436       --update-machine-info-interval=5m0s
437           Interval between machine info updates.
438
439
440       --user=""
441           The name of the kubeconfig user to use
442
443
444       --username=""
445           Username for basic authentication to the API server
446
447
448       -v, --v=0
449           number for the log level verbosity
450
451
452       --version=false
453           Print version information and quit
454
455
456       --vmodule=
457           comma-separated list of pattern=N settings for file-filtered
458       logging
459
460
461

EXAMPLE

463                # Apply the configuration in pod.json to a pod.
464                kubectl apply -f ./pod.json
465
466                # Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml.
467                kubectl apply -k dir/
468
469                # Apply the JSON passed into stdin to a pod.
470                cat pod.json | kubectl apply -f -
471
472                # Note: --prune is still in Alpha
473                # Apply the configuration in manifest.yaml that matches label app=nginx and delete all the other resources that are not in the file and match label app=nginx.
474                kubectl apply --prune -f manifest.yaml -l app=nginx
475
476                # Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file.
477                kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap
478
479
480
481

SEE ALSO

483       kubectl(1), kubectl-apply-edit-last-applied(1),
484       kubectl-apply-set-last-applied(1), kubectl-apply-view-last-applied(1),
485
486
487

HISTORY

489       January 2015, Originally compiled by Eric Paris (eparis at redhat dot
490       com) based on the kubernetes source material, but hopefully they have
491       been automatically generated since!
492
493
494
495Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum