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=false
50           If  true, only print the object that would be sent, without sending
51       it. Warning: --dry-run cannot accurately output the result  of  merging
52       the  local  manifest  and the server-side data. Use --server-dry-run to
53       get the merged result instead.
54
55
56       --experimental-field-manager="kubectl"
57           Name of the manager used to track field ownership. This is an alpha
58       feature and flag.
59
60
61       --experimental-force-conflicts=false
62           If  true,  server-side  apply  will  force the changes against con‐
63       flicts. This is an alpha feature and flag.
64
65
66       --experimental-server-side=false
67           If true, apply runs in the server instead of the client. This is an
68       alpha feature and flag.
69
70
71       -f, --filename=[]
72           that contains the configuration to apply
73
74
75       --force=false
76           Only   used   when  grace-period=0.  If  true,  immediately  remove
77       resources from API and bypass graceful deletion.  Note  that  immediate
78       deletion of some resources may result in inconsistency or data loss and
79       requires confirmation.
80
81
82       --grace-period=-1
83           Period of time in seconds given to the resource to terminate grace‐
84       fully.  Ignored  if negative. Set to 1 for immediate shutdown. Can only
85       be set to 0 when --force is true (force deletion).
86
87
88       --include-uninitialized=false
89           If true, the kubectl command applies to uninitialized  objects.  If
90       explicitly  set to false, this flag overrides other flags that make the
91       kubectl commands apply to uninitialized objects, e.g., "--all". Objects
92       with empty metadata.initializers are regarded as initialized.
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       --openapi-patch=true
101           If true, use openapi to calculate diff when  the  openapi  presents
102       and the resource can be found in the openapi spec. Otherwise, fall back
103       to use baked-in types.
104
105
106       -o, --output=""
107           Output   format.   One    of:    json|yaml|name|go-template|go-tem‐
108       plate-file|template|templatefile|jsonpath|jsonpath-file.
109
110
111       --overwrite=true
112           Automatically  resolve conflicts between the modified and live con‐
113       figuration by using values from the modified configuration
114
115
116       --prune=false
117           Automatically delete resource objects, including the  uninitialized
118       ones, that do not appear in the configs and are created by either apply
119       or create --save-config. Should be used with either -l or --all.
120
121
122       --prune-whitelist=[]
123           Overwrite  the  default  whitelist  with  <group/version/kind>  for
124       --prune
125
126
127       --record=false
128           Record  current  kubectl command in the resource annotation. If set
129       to false, do not record the command. If set to true,  record  the  com‐
130       mand.  If  not  set,  default to updating the existing annotation value
131       only if one already exists.
132
133
134       -R, --recursive=false
135           Process the directory used in -f,  --filename  recursively.  Useful
136       when  you  want  to  manage related manifests organized within the same
137       directory.
138
139
140       -l, --selector=""
141           Selector (label query)  to  filter  on,  supports  '=',  '==',  and
142       '!='.(e.g. -l key1=value1,key2=value2)
143
144
145       --server-dry-run=false
146           If  true,  request  will be sent to server with dry-run flag, which
147       means the modifications won't be persisted. This is  an  alpha  feature
148       and flag.
149
150
151       --template=""
152           Template  string  or  path  to template file to use when -o=go-tem‐
153       plate, -o=go-template-file. The template format is golang  templates  [
154http://golang.org/pkg/text/template/#pkg-overview⟩].
155
156
157       --timeout=0s
158           The length of time to wait before giving up on a delete, zero means
159       determine a timeout from the size of the object
160
161
162       --validate=true
163           If true, use a schema to validate the input before sending it
164
165
166       --wait=false
167           If true, wait for resources to be gone before returning. This waits
168       for finalizers.
169
170
171

OPTIONS INHERITED FROM PARENT COMMANDS

173       --alsologtostderr=false
174           log to standard error as well as files
175
176
177       --application-metrics-count-limit=100
178           Max number of application metrics to store (per container)
179
180
181       --as=""
182           Username to impersonate for the operation
183
184
185       --as-group=[]
186           Group  to  impersonate for the operation, this flag can be repeated
187       to specify multiple groups.
188
189
190       --azure-container-registry-config=""
191           Path to the file containing Azure container registry  configuration
192       information.
193
194
195       --boot-id-file="/proc/sys/kernel/random/boot_id"
196           Comma-separated  list  of files to check for boot-id. Use the first
197       one that exists.
198
199
200       --cache-dir="/builddir/.kube/http-cache"
201           Default HTTP cache directory
202
203
204       --certificate-authority=""
205           Path to a cert file for the certificate authority
206
207
208       --client-certificate=""
209           Path to a client certificate file for TLS
210
211
212       --client-key=""
213           Path to a client key file for TLS
214
215
216       --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
217           CIDRs opened in GCE firewall for LB traffic proxy  health checks
218
219
220       --cluster=""
221           The name of the kubeconfig cluster to use
222
223
224       --container-hints="/etc/cadvisor/container_hints.json"
225           location of the container hints file
226
227
228       --containerd="/run/containerd/containerd.sock"
229           containerd endpoint
230
231
232       --containerd-namespace="k8s.io"
233           containerd namespace
234
235
236       --context=""
237           The name of the kubeconfig context to use
238
239
240       --default-not-ready-toleration-seconds=300
241           Indicates    the    tolerationSeconds   of   the   toleration   for
242       notReady:NoExecute that is added by default to every pod that does  not
243       already have such a toleration.
244
245
246       --default-unreachable-toleration-seconds=300
247           Indicates  the  tolerationSeconds  of  the  toleration for unreach‐
248       able:NoExecute that is added by default to  every  pod  that  does  not
249       already have such a toleration.
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  fall‐
267       back, 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  sepa‐
299       rated  list  of  key values, where the keys are event types (e.g.: cre‐
300       ation, 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 (none|cpu|heap|goroutine|thread‐
369       create|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       --token=""
428           Bearer token for authentication to the API server
429
430
431       --update-machine-info-interval=5m0s
432           Interval between machine info updates.
433
434
435       --user=""
436           The name of the kubeconfig user to use
437
438
439       --username=""
440           Username for basic authentication to the API server
441
442
443       -v, --v=0
444           number for the log level verbosity
445
446
447       --version=false
448           Print version information and quit
449
450
451       --vmodule=
452           comma-separated list of pattern=N settings for  file-filtered  log‐
453       ging
454
455
456

EXAMPLE

458                # Apply the configuration in pod.json to a pod.
459                kubectl apply -f ./pod.json
460
461                # Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml.
462                kubectl apply -k dir/
463
464                # Apply the JSON passed into stdin to a pod.
465                cat pod.json | kubectl apply -f -
466
467                # Note: --prune is still in Alpha
468                # 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.
469                kubectl apply --prune -f manifest.yaml -l app=nginx
470
471                # Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file.
472                kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap
473
474
475
476

SEE ALSO

478       kubectl(1),                         kubectl-apply-edit-last-applied(1),
479       kubectl-apply-set-last-applied(1), kubectl-apply-view-last-applied(1),
480
481
482

HISTORY

484       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
485       com)  based  on the kubernetes source material, but hopefully they have
486       been automatically generated since!
487
488
489
490Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum