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 pass a
34 grace period of 0 and specify the --force flag.
35
36
37 IMPORTANT: Force deleting pods does not wait for confirmation that the
38 pod's processes have been terminated, which can leave those processes
39 running until the node detects the deletion and completes graceful
40 deletion. If your processes use shared storage or talk to a remote API
41 and depend on the name of the pod to identify themselves, force delet‐
42 ing those pods may result in multiple processes running on different
43 machines using the same identification which may lead to data corrup‐
44 tion or inconsistency. Only force delete pods when you are sure the pod
45 is terminated, or if your application can tolerate multiple copies of
46 the same pod running at once. Also, if you force delete pods the sched‐
47 uler may place new pods on those nodes before the node has released
48 those resources and causing those pods to be evicted immediately.
49
50
51 Note that the delete command does NOT do resource version checks, so if
52 someone submits an update to a resource right when you submit a delete,
53 their update will be lost along with the rest of the resource.
54
55
56
58 --all=false
59 Delete all resources, including uninitialized ones, in the names‐
60 pace of the specified resource types.
61
62
63 -A, --all-namespaces=false
64 If present, list the requested object(s) across all namespaces.
65 Namespace in current context is ignored even if specified with --names‐
66 pace.
67
68
69 --cascade=true
70 If true, cascade the deletion of the resources managed by this
71 resource (e.g. Pods created by a ReplicationController). Default true.
72
73
74 --field-selector=""
75 Selector (field query) to filter on, supports '=', '==', and
76 '!='.(e.g. --field-selector key1=value1,key2=value2). The server only
77 supports a limited number of field queries per type.
78
79
80 -f, --filename=[]
81 containing the resource to delete.
82
83
84 --force=false
85 Only used when grace-period=0. If true, immediately remove
86 resources from API and bypass graceful deletion. Note that immediate
87 deletion of some resources may result in inconsistency or data loss and
88 requires confirmation.
89
90
91 --grace-period=-1
92 Period of time in seconds given to the resource to terminate grace‐
93 fully. Ignored if negative. Set to 1 for immediate shutdown. Can only
94 be set to 0 when --force is true (force deletion).
95
96
97 --ignore-not-found=false
98 Treat "resource not found" as a successful delete. Defaults to
99 "true" when --all is specified.
100
101
102 --include-uninitialized=false
103 If true, the kubectl command applies to uninitialized objects. If
104 explicitly set to false, this flag overrides other flags that make the
105 kubectl commands apply to uninitialized objects, e.g., "--all". Objects
106 with empty metadata.initializers are regarded as initialized.
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 -R, --recursive=false
124 Process the directory used in -f, --filename recursively. Useful
125 when you want to manage related manifests organized within the same
126 directory.
127
128
129 -l, --selector=""
130 Selector (label query) to filter on, not including uninitialized
131 ones.
132
133
134 --timeout=0s
135 The length of time to wait before giving up on a delete, zero means
136 determine a timeout from the size of the object
137
138
139 --wait=true
140 If true, wait for resources to be gone before returning. This waits
141 for finalizers.
142
143
144
146 --alsologtostderr=false
147 log to standard error as well as files
148
149
150 --application-metrics-count-limit=100
151 Max number of application metrics to store (per container)
152
153
154 --as=""
155 Username to impersonate for the operation
156
157
158 --as-group=[]
159 Group to impersonate for the operation, this flag can be repeated
160 to specify multiple groups.
161
162
163 --azure-container-registry-config=""
164 Path to the file containing Azure container registry configuration
165 information.
166
167
168 --boot-id-file="/proc/sys/kernel/random/boot_id"
169 Comma-separated list of files to check for boot-id. Use the first
170 one that exists.
171
172
173 --cache-dir="/builddir/.kube/http-cache"
174 Default HTTP cache directory
175
176
177 --certificate-authority=""
178 Path to a cert file for the certificate authority
179
180
181 --client-certificate=""
182 Path to a client certificate file for TLS
183
184
185 --client-key=""
186 Path to a client key file for TLS
187
188
189 --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
190 CIDRs opened in GCE firewall for LB traffic proxy health checks
191
192
193 --cluster=""
194 The name of the kubeconfig cluster to use
195
196
197 --container-hints="/etc/cadvisor/container_hints.json"
198 location of the container hints file
199
200
201 --containerd="/run/containerd/containerd.sock"
202 containerd endpoint
203
204
205 --containerd-namespace="k8s.io"
206 containerd namespace
207
208
209 --context=""
210 The name of the kubeconfig context to use
211
212
213 --default-not-ready-toleration-seconds=300
214 Indicates the tolerationSeconds of the toleration for
215 notReady:NoExecute that is added by default to every pod that does not
216 already have such a toleration.
217
218
219 --default-unreachable-toleration-seconds=300
220 Indicates the tolerationSeconds of the toleration for unreach‐
221 able:NoExecute that is added by default to every pod that does not
222 already have such a toleration.
223
224
225 --docker="unix:///var/run/docker.sock"
226 docker endpoint
227
228
229 --docker-env-metadata-whitelist=""
230 a comma-separated list of environment variable keys that needs to
231 be collected for docker containers
232
233
234 --docker-only=false
235 Only report docker containers in addition to root stats
236
237
238 --docker-root="/var/lib/docker"
239 DEPRECATED: docker root is read from docker info (this is a fall‐
240 back, default: /var/lib/docker)
241
242
243 --docker-tls=false
244 use TLS to connect to docker
245
246
247 --docker-tls-ca="ca.pem"
248 path to trusted CA
249
250
251 --docker-tls-cert="cert.pem"
252 path to client certificate
253
254
255 --docker-tls-key="key.pem"
256 path to private key
257
258
259 --enable-load-reader=false
260 Whether to enable cpu load reader
261
262
263 --event-storage-age-limit="default=0"
264 Max length of time for which to store events (per type). Value is a
265 comma separated list of key values, where the keys are event types
266 (e.g.: creation, oom) or "default" and the value is a duration. Default
267 is applied to all non-specified event types
268
269
270 --event-storage-event-limit="default=0"
271 Max number of events to store (per type). Value is a comma sepa‐
272 rated list of key values, where the keys are event types (e.g.: cre‐
273 ation, oom) or "default" and the value is an integer. Default is
274 applied to all non-specified event types
275
276
277 --global-housekeeping-interval=1m0s
278 Interval between global housekeepings
279
280
281 --housekeeping-interval=10s
282 Interval between container housekeepings
283
284
285 --insecure-skip-tls-verify=false
286 If true, the server's certificate will not be checked for validity.
287 This will make your HTTPS connections insecure
288
289
290 --kubeconfig=""
291 Path to the kubeconfig file to use for CLI requests.
292
293
294 --log-backtrace-at=:0
295 when logging hits line file:N, emit a stack trace
296
297
298 --log-cadvisor-usage=false
299 Whether to log the usage of the cAdvisor container
300
301
302 --log-dir=""
303 If non-empty, write log files in this directory
304
305
306 --log-file=""
307 If non-empty, use this log file
308
309
310 --log-file-max-size=1800
311 Defines the maximum size a log file can grow to. Unit is megabytes.
312 If the value is 0, the maximum file size is unlimited.
313
314
315 --log-flush-frequency=5s
316 Maximum number of seconds between log flushes
317
318
319 --logtostderr=true
320 log to standard error instead of files
321
322
323 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
324 Comma-separated list of files to check for machine-id. Use the
325 first one that exists.
326
327
328 --match-server-version=false
329 Require server version to match client version
330
331
332 -n, --namespace=""
333 If present, the namespace scope for this CLI request
334
335
336 --password=""
337 Password for basic authentication to the API server
338
339
340 --profile="none"
341 Name of profile to capture. One of (none|cpu|heap|goroutine|thread‐
342 create|block|mutex)
343
344
345 --profile-output="profile.pprof"
346 Name of the file to write the profile to
347
348
349 --request-timeout="0"
350 The length of time to wait before giving up on a single server
351 request. Non-zero values should contain a corresponding time unit (e.g.
352 1s, 2m, 3h). A value of zero means don't timeout requests.
353
354
355 -s, --server=""
356 The address and port of the Kubernetes API server
357
358
359 --skip-headers=false
360 If true, avoid header prefixes in the log messages
361
362
363 --skip-log-headers=false
364 If true, avoid headers when opening log files
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 --update-machine-info-interval=5m0s
405 Interval between machine info updates.
406
407
408 --user=""
409 The name of the kubeconfig user to use
410
411
412 --username=""
413 Username for basic authentication to the API server
414
415
416 -v, --v=0
417 number for the log level verbosity
418
419
420 --version=false
421 Print version information and quit
422
423
424 --vmodule=
425 comma-separated list of pattern=N settings for file-filtered log‐
426 ging
427
428
429
431 # Delete a pod using the type and name specified in pod.json.
432 kubectl delete -f ./pod.json
433
434 # Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml.
435 kubectl delete -k dir
436
437 # Delete a pod based on the type and name in the JSON passed into stdin.
438 cat pod.json | kubectl delete -f -
439
440 # Delete pods and services with same names "baz" and "foo"
441 kubectl delete pod,service baz foo
442
443 # Delete pods and services with label name=myLabel.
444 kubectl delete pods,services -l name=myLabel
445
446 # Delete a pod with minimal delay
447 kubectl delete pod foo --now
448
449 # Force delete a pod on a dead node
450 kubectl delete pod foo --grace-period=0 --force
451
452 # Delete all pods
453 kubectl delete pods --all
454
455
456
457
459 kubectl(1),
460
461
462
464 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
465 com) based on the kubernetes source material, but hopefully they have
466 been automatically generated since!
467
468
469
470Eric Paris kubernetes User Manuals KUBERNETES(1)