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 --cascade=true
64 If true, cascade the deletion of the resources managed by this
65 resource (e.g. Pods created by a ReplicationController). Default true.
66
67
68 --field-selector=""
69 Selector (field query) to filter on, supports '=', '==', and
70 '!='.(e.g. --field-selector key1=value1,key2=value2). The server only
71 supports a limited number of field queries per type.
72
73
74 -f, --filename=[]
75 containing the resource to delete.
76
77
78 --force=false
79 Only used when grace-period=0. If true, immediately remove
80 resources from API and bypass graceful deletion. Note that immediate
81 deletion of some resources may result in inconsistency or data loss and
82 requires confirmation.
83
84
85 --grace-period=-1
86 Period of time in seconds given to the resource to terminate grace‐
87 fully. Ignored if negative. Set to 1 for immediate shutdown. Can only
88 be set to 0 when --force is true (force deletion).
89
90
91 --ignore-not-found=false
92 Treat "resource not found" as a successful delete. Defaults to
93 "true" when --all is specified.
94
95
96 --include-uninitialized=false
97 If true, the kubectl command applies to uninitialized objects. If
98 explicitly set to false, this flag overrides other flags that make the
99 kubectl commands apply to uninitialized objects, e.g., "--all". Objects
100 with empty metadata.initializers are regarded as initialized.
101
102
103 --now=false
104 If true, resources are signaled for immediate shutdown (same as
105 --grace-period=1).
106
107
108 -o, --output=""
109 Output mode. Use "-o name" for shorter output (resource/name).
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, not including uninitialized
120 ones.
121
122
123 --timeout=0s
124 The length of time to wait before giving up on a delete, zero means
125 determine a timeout from the size of the object
126
127
128 --wait=true
129 If true, wait for resources to be gone before returning. This waits
130 for finalizers.
131
132
133
135 --allow-verification-with-non-compliant-keys=false
136 Allow a SignatureVerifier to use keys which are technically
137 non-compliant with RFC6962.
138
139
140 --alsologtostderr=false
141 log to standard error as well as files
142
143
144 --application-metrics-count-limit=100
145 Max number of application metrics to store (per container)
146
147
148 --as=""
149 Username to impersonate for the operation
150
151
152 --as-group=[]
153 Group to impersonate for the operation, this flag can be repeated
154 to specify multiple groups.
155
156
157 --azure-container-registry-config=""
158 Path to the file containing Azure container registry configuration
159 information.
160
161
162 --boot-id-file="/proc/sys/kernel/random/boot_id"
163 Comma-separated list of files to check for boot-id. Use the first
164 one that exists.
165
166
167 --cache-dir="/builddir/.kube/http-cache"
168 Default HTTP cache directory
169
170
171 --certificate-authority=""
172 Path to a cert file for the certificate authority
173
174
175 --client-certificate=""
176 Path to a client certificate file for TLS
177
178
179 --client-key=""
180 Path to a client key file for TLS
181
182
183 --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
184 CIDRs opened in GCE firewall for LB traffic proxy health checks
185
186
187 --cluster=""
188 The name of the kubeconfig cluster to use
189
190
191 --container-hints="/etc/cadvisor/container_hints.json"
192 location of the container hints file
193
194
195 --containerd="unix:///var/run/containerd.sock"
196 containerd endpoint
197
198
199 --context=""
200 The name of the kubeconfig context to use
201
202
203 --default-not-ready-toleration-seconds=300
204 Indicates the tolerationSeconds of the toleration for
205 notReady:NoExecute that is added by default to every pod that does not
206 already have such a toleration.
207
208
209 --default-unreachable-toleration-seconds=300
210 Indicates the tolerationSeconds of the toleration for unreach‐
211 able:NoExecute that is added by default to every pod that does not
212 already have such a toleration.
213
214
215 --docker="unix:///var/run/docker.sock"
216 docker endpoint
217
218
219 --docker-env-metadata-whitelist=""
220 a comma-separated list of environment variable keys that needs to
221 be collected for docker containers
222
223
224 --docker-only=false
225 Only report docker containers in addition to root stats
226
227
228 --docker-root="/var/lib/docker"
229 DEPRECATED: docker root is read from docker info (this is a fall‐
230 back, default: /var/lib/docker)
231
232
233 --docker-tls=false
234 use TLS to connect to docker
235
236
237 --docker-tls-ca="ca.pem"
238 path to trusted CA
239
240
241 --docker-tls-cert="cert.pem"
242 path to client certificate
243
244
245 --docker-tls-key="key.pem"
246 path to private key
247
248
249 --enable-load-reader=false
250 Whether to enable cpu load reader
251
252
253 --event-storage-age-limit="default=0"
254 Max length of time for which to store events (per type). Value is a
255 comma separated list of key values, where the keys are event types
256 (e.g.: creation, oom) or "default" and the value is a duration. Default
257 is applied to all non-specified event types
258
259
260 --event-storage-event-limit="default=0"
261 Max number of events to store (per type). Value is a comma sepa‐
262 rated list of key values, where the keys are event types (e.g.: cre‐
263 ation, oom) or "default" and the value is an integer. Default is
264 applied to all non-specified event types
265
266
267 --global-housekeeping-interval=1m0s
268 Interval between global housekeepings
269
270
271 --google-json-key=""
272 The Google Cloud Platform Service Account JSON Key to use for
273 authentication.
274
275
276 --housekeeping-interval=10s
277 Interval between container housekeepings
278
279
280 --insecure-skip-tls-verify=false
281 If true, the server's certificate will not be checked for validity.
282 This will make your HTTPS connections insecure
283
284
285 --kubeconfig=""
286 Path to the kubeconfig file to use for CLI requests.
287
288
289 --log-backtrace-at=:0
290 when logging hits line file:N, emit a stack trace
291
292
293 --log-cadvisor-usage=false
294 Whether to log the usage of the cAdvisor container
295
296
297 --log-dir=""
298 If non-empty, write log files in this directory
299
300
301 --log-flush-frequency=5s
302 Maximum number of seconds between log flushes
303
304
305 --logtostderr=true
306 log to standard error instead of files
307
308
309 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
310 Comma-separated list of files to check for machine-id. Use the
311 first one that exists.
312
313
314 --match-server-version=false
315 Require server version to match client version
316
317
318 --mesos-agent="127.0.0.1:5051"
319 Mesos agent address
320
321
322 --mesos-agent-timeout=10s
323 Mesos agent timeout
324
325
326 -n, --namespace=""
327 If present, the namespace scope for this CLI request
328
329
330 --request-timeout="0"
331 The length of time to wait before giving up on a single server
332 request. Non-zero values should contain a corresponding time unit (e.g.
333 1s, 2m, 3h). A value of zero means don't timeout requests.
334
335
336 -s, --server=""
337 The address and port of the Kubernetes API server
338
339
340 --stderrthreshold=2
341 logs at or above this threshold go to stderr
342
343
344 --storage-driver-buffer-duration=1m0s
345 Writes in the storage driver will be buffered for this duration,
346 and committed to the non memory backends as a single transaction
347
348
349 --storage-driver-db="cadvisor"
350 database name
351
352
353 --storage-driver-host="localhost:8086"
354 database host:port
355
356
357 --storage-driver-password="root"
358 database password
359
360
361 --storage-driver-secure=false
362 use secure connection with database
363
364
365 --storage-driver-table="stats"
366 table name
367
368
369 --storage-driver-user="root"
370 database username
371
372
373 --token=""
374 Bearer token for authentication to the API server
375
376
377 --user=""
378 The name of the kubeconfig user to use
379
380
381 -v, --v=0
382 log level for V logs
383
384
385 --version=false
386 Print version information and quit
387
388
389 --vmodule=
390 comma-separated list of pattern=N settings for file-filtered log‐
391 ging
392
393
394
396 # Delete a pod using the type and name specified in pod.json.
397 kubectl delete -f ./pod.json
398
399 # Delete a pod based on the type and name in the JSON passed into stdin.
400 cat pod.json | kubectl delete -f -
401
402 # Delete pods and services with same names "baz" and "foo"
403 kubectl delete pod,service baz foo
404
405 # Delete pods and services with label name=myLabel.
406 kubectl delete pods,services -l name=myLabel
407
408 # Delete a pod with minimal delay
409 kubectl delete pod foo --now
410
411 # Force delete a pod on a dead node
412 kubectl delete pod foo --grace-period=0 --force
413
414 # Delete all pods
415 kubectl delete pods --all
416
417
418
419
421 kubectl(1),
422
423
424
426 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
427 com) based on the kubernetes source material, but hopefully they have
428 been automatically generated since!
429
430
431
432Eric Paris kubernetes User Manuals KUBERNETES(1)