1KUBERNETES(1) Jan 2015 KUBERNETES(1)
2
3
4
6 kubectl delete - Delete resources by filenames, stdin, resources and
7 names, or by resources and label selector
8
9
10
12 kubectl delete [OPTIONS]
13
14
15
17 Delete resources by filenames, stdin, resources and names, or by
18 resources and label selector.
19
20
21 JSON and YAML formats are accepted. Only one type of the arguments may
22 be specified: filenames, resources and names, or resources and label
23 selector.
24
25
26 Some resources, such as pods, support graceful deletion. These
27 resources define a default period before they are forcibly terminated
28 (the grace period) but you may override that value with the
29 --grace-period flag, or pass --now to set a grace-period of 1. Because
30 these resources often represent entities in the cluster, deletion may
31 not be acknowledged immediately. If the node hosting a pod is down or
32 cannot reach the API server, termination may take significantly longer
33 than the grace period. To force delete a resource, you must specify the
34 --force flag. Note: only a subset of resources support graceful
35 deletion. In absence of the support, --grace-period is ignored.
36
37
38 IMPORTANT: Force deleting pods does not wait for confirmation that the
39 pod's processes have been terminated, which can leave those processes
40 running until the node detects the deletion and completes graceful
41 deletion. If your processes use shared storage or talk to a remote API
42 and depend on the name of the pod to identify themselves, force
43 deleting those pods may result in multiple processes running on
44 different machines using the same identification which may lead to data
45 corruption or inconsistency. Only force delete pods when you are sure
46 the pod is terminated, or if your application can tolerate multiple
47 copies of the same pod running at once. Also, if you force delete pods
48 the scheduler may place new pods on those nodes before the node has
49 released those resources and causing those pods to be evicted
50 immediately.
51
52
53 Note that the delete command does NOT do resource version checks, so if
54 someone submits an update to a resource right when you submit a delete,
55 their update will be lost along with the rest of the resource.
56
57
58
60 --all=false
61 Delete all resources, including uninitialized ones, in the
62 namespace of the specified resource types.
63
64
65 -A, --all-namespaces=false
66 If present, list the requested object(s) across all namespaces.
67 Namespace in current context is ignored even if specified with
68 --namespace.
69
70
71 --cascade=true
72 If true, cascade the deletion of the resources managed by this
73 resource (e.g. Pods created by a ReplicationController). Default true.
74
75
76 --dry-run="none"
77 Must be "none", "server", or "client". If client strategy, only
78 print the object that would be sent, without sending it. If server
79 strategy, submit server-side request without persisting the resource.
80
81
82 --field-selector=""
83 Selector (field query) to filter on, supports '=', '==', and
84 '!='.(e.g. --field-selector key1=value1,key2=value2). The server only
85 supports a limited number of field queries per type.
86
87
88 -f, --filename=[]
89 containing the resource to delete.
90
91
92 --force=false
93 If true, immediately remove resources from API and bypass graceful
94 deletion. Note that immediate deletion of some resources may result in
95 inconsistency or data loss and requires confirmation.
96
97
98 --grace-period=-1
99 Period of time in seconds given to the resource to terminate
100 gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can
101 only be set to 0 when --force is true (force deletion).
102
103
104 --ignore-not-found=false
105 Treat "resource not found" as a successful delete. Defaults to
106 "true" when --all is specified.
107
108
109 -k, --kustomize=""
110 Process a kustomization directory. This flag can't be used together
111 with -f or -R.
112
113
114 --now=false
115 If true, resources are signaled for immediate shutdown (same as
116 --grace-period=1).
117
118
119 -o, --output=""
120 Output mode. Use "-o name" for shorter output (resource/name).
121
122
123 --raw=""
124 Raw URI to DELETE to the server. Uses the transport specified by
125 the kubeconfig file.
126
127
128 -R, --recursive=false
129 Process the directory used in -f, --filename recursively. Useful
130 when you want to manage related manifests organized within the same
131 directory.
132
133
134 -l, --selector=""
135 Selector (label query) to filter on, not including uninitialized
136 ones.
137
138
139 --timeout=0s
140 The length of time to wait before giving up on a delete, zero means
141 determine a timeout from the size of the object
142
143
144 --wait=true
145 If true, wait for resources to be gone before returning. This waits
146 for finalizers.
147
148
149
151 --add-dir-header=false
152 If true, adds the file directory to the header
153
154
155 --alsologtostderr=false
156 log to standard error as well as files
157
158
159 --application-metrics-count-limit=100
160 Max number of application metrics to store (per container)
161
162
163 --as=""
164 Username to impersonate for the operation
165
166
167 --as-group=[]
168 Group to impersonate for the operation, this flag can be repeated
169 to specify multiple groups.
170
171
172 --azure-container-registry-config=""
173 Path to the file containing Azure container registry configuration
174 information.
175
176
177 --boot-id-file="/proc/sys/kernel/random/boot_id"
178 Comma-separated list of files to check for boot-id. Use the first
179 one that exists.
180
181
182 --cache-dir="/builddir/.kube/http-cache"
183 Default HTTP cache directory
184
185
186 --certificate-authority=""
187 Path to a cert file for the certificate authority
188
189
190 --client-certificate=""
191 Path to a client certificate file for TLS
192
193
194 --client-key=""
195 Path to a client key file for TLS
196
197
198 --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
199 CIDRs opened in GCE firewall for L7 LB traffic proxy health checks
200
201
202 --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
203 CIDRs opened in GCE firewall for L4 LB traffic proxy health checks
204
205
206 --cluster=""
207 The name of the kubeconfig cluster to use
208
209
210 --container-hints="/etc/cadvisor/container_hints.json"
211 location of the container hints file
212
213
214 --containerd="/run/containerd/containerd.sock"
215 containerd endpoint
216
217
218 --containerd-namespace="k8s.io"
219 containerd namespace
220
221
222 --context=""
223 The name of the kubeconfig context to use
224
225
226 --default-not-ready-toleration-seconds=300
227 Indicates the tolerationSeconds of the toleration for
228 notReady:NoExecute that is added by default to every pod that does not
229 already have such a toleration.
230
231
232 --default-unreachable-toleration-seconds=300
233 Indicates the tolerationSeconds of the toleration for
234 unreachable:NoExecute that is added by default to every pod that does
235 not already have such a toleration.
236
237
238 --disable-root-cgroup-stats=false
239 Disable collecting root Cgroup stats
240
241
242 --docker="unix:///var/run/docker.sock"
243 docker endpoint
244
245
246 --docker-env-metadata-whitelist=""
247 a comma-separated list of environment variable keys that needs to
248 be collected for docker containers
249
250
251 --docker-only=false
252 Only report docker containers in addition to root stats
253
254
255 --docker-root="/var/lib/docker"
256 DEPRECATED: docker root is read from docker info (this is a
257 fallback, default: /var/lib/docker)
258
259
260 --docker-tls=false
261 use TLS to connect to docker
262
263
264 --docker-tls-ca="ca.pem"
265 path to trusted CA
266
267
268 --docker-tls-cert="cert.pem"
269 path to client certificate
270
271
272 --docker-tls-key="key.pem"
273 path to private key
274
275
276 --enable-load-reader=false
277 Whether to enable cpu load reader
278
279
280 --event-storage-age-limit="default=0"
281 Max length of time for which to store events (per type). Value is a
282 comma separated list of key values, where the keys are event types
283 (e.g.: creation, oom) or "default" and the value is a duration. Default
284 is applied to all non-specified event types
285
286
287 --event-storage-event-limit="default=0"
288 Max number of events to store (per type). Value is a comma
289 separated list of key values, where the keys are event types (e.g.:
290 creation, oom) or "default" and the value is an integer. Default is
291 applied to all non-specified event types
292
293
294 --global-housekeeping-interval=1m0s
295 Interval between global housekeepings
296
297
298 --housekeeping-interval=10s
299 Interval between container housekeepings
300
301
302 --insecure-skip-tls-verify=false
303 If true, the server's certificate will not be checked for validity.
304 This will make your HTTPS connections insecure
305
306
307 --kubeconfig=""
308 Path to the kubeconfig file to use for CLI requests.
309
310
311 --log-backtrace-at=:0
312 when logging hits line file:N, emit a stack trace
313
314
315 --log-cadvisor-usage=false
316 Whether to log the usage of the cAdvisor container
317
318
319 --log-dir=""
320 If non-empty, write log files in this directory
321
322
323 --log-file=""
324 If non-empty, use this log file
325
326
327 --log-file-max-size=1800
328 Defines the maximum size a log file can grow to. Unit is megabytes.
329 If the value is 0, the maximum file size is unlimited.
330
331
332 --log-flush-frequency=5s
333 Maximum number of seconds between log flushes
334
335
336 --logtostderr=true
337 log to standard error instead of files
338
339
340 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
341 Comma-separated list of files to check for machine-id. Use the
342 first one that exists.
343
344
345 --match-server-version=false
346 Require server version to match client version
347
348
349 -n, --namespace=""
350 If present, the namespace scope for this CLI request
351
352
353 --password=""
354 Password for basic authentication to the API server
355
356
357 --profile="none"
358 Name of profile to capture. One of
359 (none|cpu|heap|goroutine|threadcreate|block|mutex)
360
361
362 --profile-output="profile.pprof"
363 Name of the file to write the profile to
364
365
366 --request-timeout="0"
367 The length of time to wait before giving up on a single server
368 request. Non-zero values should contain a corresponding time unit (e.g.
369 1s, 2m, 3h). A value of zero means don't timeout requests.
370
371
372 -s, --server=""
373 The address and port of the Kubernetes API server
374
375
376 --skip-headers=false
377 If true, avoid header prefixes in the log messages
378
379
380 --skip-log-headers=false
381 If true, avoid headers when opening log files
382
383
384 --stderrthreshold=2
385 logs at or above this threshold go to stderr
386
387
388 --storage-driver-buffer-duration=1m0s
389 Writes in the storage driver will be buffered for this duration,
390 and committed to the non memory backends as a single transaction
391
392
393 --storage-driver-db="cadvisor"
394 database name
395
396
397 --storage-driver-host="localhost:8086"
398 database host:port
399
400
401 --storage-driver-password="root"
402 database password
403
404
405 --storage-driver-secure=false
406 use secure connection with database
407
408
409 --storage-driver-table="stats"
410 table name
411
412
413 --storage-driver-user="root"
414 database username
415
416
417 --tls-server-name=""
418 Server name to use for server certificate validation. If it is not
419 provided, the hostname used to contact the server is used
420
421
422 --token=""
423 Bearer token for authentication to the API server
424
425
426 --update-machine-info-interval=5m0s
427 Interval between machine info updates.
428
429
430 --user=""
431 The name of the kubeconfig user to use
432
433
434 --username=""
435 Username for basic authentication to the API server
436
437
438 -v, --v=0
439 number for the log level verbosity
440
441
442 --version=false
443 Print version information and quit
444
445
446 --vmodule=
447 comma-separated list of pattern=N settings for file-filtered
448 logging
449
450
451
453 # Delete a pod using the type and name specified in pod.json.
454 kubectl delete -f ./pod.json
455
456 # Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml.
457 kubectl delete -k dir
458
459 # Delete a pod based on the type and name in the JSON passed into stdin.
460 cat pod.json | kubectl delete -f -
461
462 # Delete pods and services with same names "baz" and "foo"
463 kubectl delete pod,service baz foo
464
465 # Delete pods and services with label name=myLabel.
466 kubectl delete pods,services -l name=myLabel
467
468 # Delete a pod with minimal delay
469 kubectl delete pod foo --now
470
471 # Force delete a pod on a dead node
472 kubectl delete pod foo --force
473
474 # Delete all pods
475 kubectl delete pods --all
476
477
478
479
481 kubectl(1),
482
483
484
486 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
487 com) based on the kubernetes source material, but hopefully they have
488 been automatically generated since!
489
490
491
492Eric Paris kubernetes User Manuals KUBERNETES(1)