1KUBERNETES(1) Jan 2015 KUBERNETES(1)
2
3
4
6 kubectl apply - Apply a configuration to a resource by filename or
7 stdin
8
9
10
12 kubectl apply [OPTIONS]
13
14
15
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
28 ⟨https://issues.k8s.io/34274⟩.
29
30
31
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.
52
53
54 -f, --filename=[]
55 that contains the configuration to apply
56
57
58 --force=false
59 Only used when grace-period=0. If true, immediately remove
60 resources from API and bypass graceful deletion. Note that immediate
61 deletion of some resources may result in inconsistency or data loss and
62 requires confirmation.
63
64
65 --grace-period=-1
66 Period of time in seconds given to the resource to terminate grace‐
67 fully. Ignored if negative. Set to 1 for immediate shutdown. Can only
68 be set to 0 when --force is true (force deletion).
69
70
71 --include-uninitialized=false
72 If true, the kubectl command applies to uninitialized objects. If
73 explicitly set to false, this flag overrides other flags that make the
74 kubectl commands apply to uninitialized objects, e.g., "--all". Objects
75 with empty metadata.initializers are regarded as initialized.
76
77
78 --openapi-patch=true
79 If true, use openapi to calculate diff when the openapi presents
80 and the resource can be found in the openapi spec. Otherwise, fall back
81 to use baked-in types.
82
83
84 -o, --output=""
85 Output format. One of: json|yaml|name|go-template|go-tem‐
86 plate-file|template|templatefile|jsonpath|jsonpath-file.
87
88
89 --overwrite=true
90 Automatically resolve conflicts between the modified and live con‐
91 figuration by using values from the modified configuration
92
93
94 --prune=false
95 Automatically delete resource objects, including the uninitialized
96 ones, that do not appear in the configs and are created by either apply
97 or create --save-config. Should be used with either -l or --all.
98
99
100 --prune-whitelist=[]
101 Overwrite the default whitelist with <group/version/kind> for
102 --prune
103
104
105 --record=false
106 Record current kubectl command in the resource annotation. If set
107 to false, do not record the command. If set to true, record the com‐
108 mand. If not set, default to updating the existing annotation value
109 only if one already exists.
110
111
112 -R, --recursive=false
113 Process the directory used in -f, --filename recursively. Useful
114 when you want to manage related manifests organized within the same
115 directory.
116
117
118 -l, --selector=""
119 Selector (label query) to filter on, supports '=', '==', and
120 '!='.(e.g. -l key1=value1,key2=value2)
121
122
123 --server-dry-run=false
124 If true, request will be sent to server with dry-run flag, which
125 means the modifications won't be persisted. This is an alpha feature
126 and flag.
127
128
129 --template=""
130 Template string or path to template file to use when -o=go-tem‐
131 plate, -o=go-template-file. The template format is golang templates [
132 ⟨http://golang.org/pkg/text/template/#pkg-overview⟩].
133
134
135 --timeout=0s
136 The length of time to wait before giving up on a delete, zero means
137 determine a timeout from the size of the object
138
139
140 --validate=true
141 If true, use a schema to validate the input before sending it
142
143
144 --wait=false
145 If true, wait for resources to be gone before returning. This waits
146 for finalizers.
147
148
149
151 --alsologtostderr=false
152 log to standard error as well as files
153
154
155 --application-metrics-count-limit=100
156 Max number of application metrics to store (per container)
157
158
159 --as=""
160 Username to impersonate for the operation
161
162
163 --as-group=[]
164 Group to impersonate for the operation, this flag can be repeated
165 to specify multiple groups.
166
167
168 --azure-container-registry-config=""
169 Path to the file containing Azure container registry configuration
170 information.
171
172
173 --boot-id-file="/proc/sys/kernel/random/boot_id"
174 Comma-separated list of files to check for boot-id. Use the first
175 one that exists.
176
177
178 --cache-dir="/builddir/.kube/http-cache"
179 Default HTTP cache directory
180
181
182 --certificate-authority=""
183 Path to a cert file for the certificate authority
184
185
186 --client-certificate=""
187 Path to a client certificate file for TLS
188
189
190 --client-key=""
191 Path to a client key file for TLS
192
193
194 --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
195 CIDRs opened in GCE firewall for LB traffic proxy health checks
196
197
198 --cluster=""
199 The name of the kubeconfig cluster to use
200
201
202 --container-hints="/etc/cadvisor/container_hints.json"
203 location of the container hints file
204
205
206 --containerd="unix:///var/run/containerd.sock"
207 containerd endpoint
208
209
210 --context=""
211 The name of the kubeconfig context to use
212
213
214 --default-not-ready-toleration-seconds=300
215 Indicates the tolerationSeconds of the toleration for
216 notReady:NoExecute that is added by default to every pod that does not
217 already have such a toleration.
218
219
220 --default-unreachable-toleration-seconds=300
221 Indicates the tolerationSeconds of the toleration for unreach‐
222 able:NoExecute that is added by default to every pod that does not
223 already have such a toleration.
224
225
226 --docker="unix:///var/run/docker.sock"
227 docker endpoint
228
229
230 --docker-env-metadata-whitelist=""
231 a comma-separated list of environment variable keys that needs to
232 be collected for docker containers
233
234
235 --docker-only=false
236 Only report docker containers in addition to root stats
237
238
239 --docker-root="/var/lib/docker"
240 DEPRECATED: docker root is read from docker info (this is a fall‐
241 back, default: /var/lib/docker)
242
243
244 --docker-tls=false
245 use TLS to connect to docker
246
247
248 --docker-tls-ca="ca.pem"
249 path to trusted CA
250
251
252 --docker-tls-cert="cert.pem"
253 path to client certificate
254
255
256 --docker-tls-key="key.pem"
257 path to private key
258
259
260 --enable-load-reader=false
261 Whether to enable cpu load reader
262
263
264 --event-storage-age-limit="default=0"
265 Max length of time for which to store events (per type). Value is a
266 comma separated list of key values, where the keys are event types
267 (e.g.: creation, oom) or "default" and the value is a duration. Default
268 is applied to all non-specified event types
269
270
271 --event-storage-event-limit="default=0"
272 Max number of events to store (per type). Value is a comma sepa‐
273 rated list of key values, where the keys are event types (e.g.: cre‐
274 ation, oom) or "default" and the value is an integer. Default is
275 applied to all non-specified event types
276
277
278 --global-housekeeping-interval=1m0s
279 Interval between global housekeepings
280
281
282 --housekeeping-interval=10s
283 Interval between container housekeepings
284
285
286 --insecure-skip-tls-verify=false
287 If true, the server's certificate will not be checked for validity.
288 This will make your HTTPS connections insecure
289
290
291 --kubeconfig=""
292 Path to the kubeconfig file to use for CLI requests.
293
294
295 --log-backtrace-at=:0
296 when logging hits line file:N, emit a stack trace
297
298
299 --log-cadvisor-usage=false
300 Whether to log the usage of the cAdvisor container
301
302
303 --log-dir=""
304 If non-empty, write log files in this directory
305
306
307 --log-file=""
308 If non-empty, use this log file
309
310
311 --log-flush-frequency=5s
312 Maximum number of seconds between log flushes
313
314
315 --logtostderr=true
316 log to standard error instead of files
317
318
319 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
320 Comma-separated list of files to check for machine-id. Use the
321 first one that exists.
322
323
324 --match-server-version=false
325 Require server version to match client version
326
327
328 --mesos-agent="127.0.0.1:5051"
329 Mesos agent address
330
331
332 --mesos-agent-timeout=10s
333 Mesos agent timeout
334
335
336 -n, --namespace=""
337 If present, the namespace scope for this CLI request
338
339
340 --password=""
341 Password for basic authentication to the API server
342
343
344 --profile="none"
345 Name of profile to capture. One of (none|cpu|heap|goroutine|thread‐
346 create|block|mutex)
347
348
349 --profile-output="profile.pprof"
350 Name of the file to write the profile to
351
352
353 --request-timeout="0"
354 The length of time to wait before giving up on a single server
355 request. Non-zero values should contain a corresponding time unit (e.g.
356 1s, 2m, 3h). A value of zero means don't timeout requests.
357
358
359 -s, --server=""
360 The address and port of the Kubernetes API server
361
362
363 --skip-headers=false
364 If true, avoid header prefixes in the log messages
365
366
367 --stderrthreshold=2
368 logs at or above this threshold go to stderr
369
370
371 --storage-driver-buffer-duration=1m0s
372 Writes in the storage driver will be buffered for this duration,
373 and committed to the non memory backends as a single transaction
374
375
376 --storage-driver-db="cadvisor"
377 database name
378
379
380 --storage-driver-host="localhost:8086"
381 database host:port
382
383
384 --storage-driver-password="root"
385 database password
386
387
388 --storage-driver-secure=false
389 use secure connection with database
390
391
392 --storage-driver-table="stats"
393 table name
394
395
396 --storage-driver-user="root"
397 database username
398
399
400 --token=""
401 Bearer token for authentication to the API server
402
403
404 --user=""
405 The name of the kubeconfig user to use
406
407
408 --username=""
409 Username for basic authentication to the API server
410
411
412 -v, --v=0
413 log level for V logs
414
415
416 --version=false
417 Print version information and quit
418
419
420 --vmodule=
421 comma-separated list of pattern=N settings for file-filtered log‐
422 ging
423
424
425
427 # Apply the configuration in pod.json to a pod.
428 kubectl apply -f ./pod.json
429
430 # Apply the JSON passed into stdin to a pod.
431 cat pod.json | kubectl apply -f -
432
433 # Note: --prune is still in Alpha
434 # 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.
435 kubectl apply --prune -f manifest.yaml -l app=nginx
436
437 # Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file.
438 kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap
439
440
441
442
444 kubectl(1), kubectl-apply-edit-last-applied(1),
445 kubectl-apply-set-last-applied(1), kubectl-apply-view-last-applied(1),
446
447
448
450 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
451 com) based on the kubernetes source material, but hopefully they have
452 been automatically generated since!
453
454
455
456Eric Paris kubernetes User Manuals KUBERNETES(1)