1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl  delete  -  Delete resources by filenames, stdin, resources and
10       names, or by resources and label selector
11
12
13

SYNOPSIS

15       kubectl delete [OPTIONS]
16
17
18

DESCRIPTION

20       Delete resources by filenames, stdin, resources and names,  or  by  re‐
21       sources and label selector.
22
23
24       JSON  and YAML formats are accepted. Only one type of the arguments may
25       be specified: filenames, resources and names, or  resources  and  label
26       selector.
27
28
29       Some  resources,  such  as  pods,  support graceful deletion. These re‐
30       sources define a default period before  they  are  forcibly  terminated
31       (the grace period) but you may override that value with the --grace-pe‐
32       riod flag, or pass --now to set a grace-period of 1. Because these  re‐
33       sources  often  represent  entities in the cluster, deletion may not be
34       acknowledged immediately. If the node hosting a pod is down  or  cannot
35       reach  the  API  server, termination may take significantly longer than
36       the grace period. To force delete a  resource,  you  must  specify  the
37       --force  flag.  Note: only a subset of resources support graceful dele‐
38       tion. In absence of the support, --grace-period is ignored.
39
40
41       IMPORTANT: Force deleting pods does not wait for confirmation that  the
42       pod's  processes  have been terminated, which can leave those processes
43       running until the node detects  the  deletion  and  completes  graceful
44       deletion.  If your processes use shared storage or talk to a remote API
45       and depend on the name of the pod to identify themselves, force  delet‐
46       ing  those  pods  may result in multiple processes running on different
47       machines using the same identification which may lead to  data  corrup‐
48       tion or inconsistency. Only force delete pods when you are sure the pod
49       is terminated, or if your application can tolerate multiple  copies  of
50       the same pod running at once. Also, if you force delete pods the sched‐
51       uler may place new pods on those nodes before  the  node  has  released
52       those resources and causing those pods to be evicted immediately.
53
54
55       Note that the delete command does NOT do resource version checks, so if
56       someone submits an update to a resource right when you submit a delete,
57       their update will be lost along with the rest of the resource.
58
59
60

OPTIONS

62       --all=false      Delete all resources, including uninitialized ones, in
63       the namespace of the specified resource types.
64
65
66       -A, --all-namespaces=false      If  present,  list  the  requested  ob‐
67       ject(s)  across all namespaces. Namespace in current context is ignored
68       even if specified with --namespace.
69
70
71       --cascade="background"      Must be "background", "orphan",  or  "fore‐
72       ground".  Selects  the  deletion  cascading strategy for the dependents
73       (e.g. Pods created by a ReplicationController). Defaults to background.
74
75
76       --dry-run="none"      Must be "none", "server", or "client". If  client
77       strategy, only print the object that would be sent, without sending it.
78       If server strategy, submit server-side request without  persisting  the
79       resource.
80
81
82       --field-selector=""       Selector (field query) to filter on, supports
83       '=', '==', and  '!='.(e.g.  --field-selector  key1=value1,key2=value2).
84       The server only supports a limited number of field queries per type.
85
86
87       -f, --filename=[]      containing the resource to delete.
88
89
90       --force=false       If  true, immediately remove resources from API and
91       bypass graceful deletion. Note that  immediate  deletion  of  some  re‐
92       sources may result in inconsistency or data loss and requires confirma‐
93       tion.
94
95
96       --grace-period=-1      Period of time in seconds given to the  resource
97       to  terminate  gracefully.  Ignored if negative. Set to 1 for immediate
98       shutdown. Can only be set to 0 when --force is true (force deletion).
99
100
101       --ignore-not-found=false      Treat "resource not found" as a  success‐
102       ful delete. Defaults to "true" when --all is specified.
103
104
105       -k,  --kustomize=""       Process  a kustomization directory. This flag
106       can't be used together with -f or -R.
107
108
109       --now=false      If true, resources are signaled for immediate shutdown
110       (same as --grace-period=1).
111
112
113       -o, --output=""      Output mode. Use "-o name" for shorter output (re‐
114       source/name).
115
116
117       --raw=""      Raw URI to DELETE to  the  server.   Uses  the  transport
118       specified by the kubeconfig file.
119
120
121       -R, --recursive=false      Process the directory used in -f, --filename
122       recursively. Useful when you want to manage related manifests organized
123       within the same directory.
124
125
126       -l, --selector=""      Selector (label query) to filter on, not includ‐
127       ing uninitialized ones.
128
129
130       --timeout=0s      The length of time to wait  before  giving  up  on  a
131       delete, zero means determine a timeout from the size of the object
132
133
134       --wait=true       If true, wait for resources to be gone before return‐
135       ing. This waits for finalizers.
136
137
138

OPTIONS INHERITED FROM PARENT COMMANDS

140       --add-dir-header=false      If true, adds the  file  directory  to  the
141       header of the log messages
142
143
144       --alsologtostderr=false      log to standard error as well as files
145
146
147       --application-metrics-count-limit=100       Max  number  of application
148       metrics to store (per container)
149
150
151       --as=""      Username to impersonate for the operation
152
153
154       --as-group=[]      Group to impersonate for the  operation,  this  flag
155       can be repeated to specify multiple groups.
156
157
158       --azure-container-registry-config=""       Path  to the file containing
159       Azure container registry configuration information.
160
161
162       --boot-id-file="/proc/sys/kernel/random/boot_id"        Comma-separated
163       list of files to check for boot-id. Use the first one that exists.
164
165
166       --cache-dir="/builddir/.kube/cache"      Default cache directory
167
168
169       --certificate-authority=""      Path to a cert file for the certificate
170       authority
171
172
173       --client-certificate=""      Path to a client certificate file for TLS
174
175
176       --client-key=""      Path to a client key file for TLS
177
178
179       --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
180            CIDRs  opened  in  GCE  firewall  for  L7 LB traffic proxy  health
181       checks
182
183
184       --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
185            CIDRs  opened  in  GCE  firewall  for  L4 LB traffic proxy  health
186       checks
187
188
189       --cluster=""      The name of the kubeconfig cluster to use
190
191
192       --container-hints="/etc/cadvisor/container_hints.json"      location of
193       the container hints file
194
195
196       --containerd="/run/containerd/containerd.sock"      containerd endpoint
197
198
199       --containerd-namespace="k8s.io"      containerd namespace
200
201
202       --context=""      The name of the kubeconfig context to use
203
204
205       --default-not-ready-toleration-seconds=300       Indicates  the tolera‐
206       tionSeconds of the toleration for notReady:NoExecute that is  added  by
207       default to every pod that does not already have such a toleration.
208
209
210       --default-unreachable-toleration-seconds=300      Indicates the tolera‐
211       tionSeconds of the toleration for unreachable:NoExecute that  is  added
212       by default to every pod that does not already have such a toleration.
213
214
215       --disable-root-cgroup-stats=false       Disable  collecting root Cgroup
216       stats
217
218
219       --docker="unix:///var/run/docker.sock"      docker endpoint
220
221
222       --docker-env-metadata-whitelist=""      a comma-separated list of envi‐
223       ronment  variable  keys  matched with specified prefix that needs to be
224       collected for docker containers
225
226
227       --docker-only=false      Only report docker containers in  addition  to
228       root stats
229
230
231       --docker-root="/var/lib/docker"       DEPRECATED:  docker  root is read
232       from docker info (this is a fallback, default: /var/lib/docker)
233
234
235       --docker-tls=false      use TLS to connect to docker
236
237
238       --docker-tls-ca="ca.pem"      path to trusted CA
239
240
241       --docker-tls-cert="cert.pem"      path to client certificate
242
243
244       --docker-tls-key="key.pem"      path to private key
245
246
247       --enable-load-reader=false      Whether to enable cpu load reader
248
249
250       --event-storage-age-limit="default=0"      Max length of time for which
251       to store events (per type). Value is a comma separated list of key val‐
252       ues, where the keys are event types (e.g.: creation, oom) or  "default"
253       and  the  value  is a duration. Default is applied to all non-specified
254       event types
255
256
257       --event-storage-event-limit="default=0"      Max number  of  events  to
258       store  (per type). Value is a comma separated list of key values, where
259       the keys are event types (e.g.: creation, oom)  or  "default"  and  the
260       value  is  an  integer.  Default  is applied to all non-specified event
261       types
262
263
264       --global-housekeeping-interval=1m0s      Interval between global house‐
265       keepings
266
267
268       --housekeeping-interval=10s       Interval between container housekeep‐
269       ings
270
271
272       --insecure-skip-tls-verify=false      If true, the server's certificate
273       will not be checked for validity. This will make your HTTPS connections
274       insecure
275
276
277       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
278       quests.
279
280
281       --log-backtrace-at=:0       when logging hits line file:N, emit a stack
282       trace
283
284
285       --log-cadvisor-usage=false      Whether to log the usage of the  cAdvi‐
286       sor container
287
288
289       --log-dir=""      If non-empty, write log files in this directory
290
291
292       --log-file=""      If non-empty, use this log file
293
294
295       --log-file-max-size=1800       Defines  the maximum size a log file can
296       grow to. Unit is megabytes. If the value is 0, the maximum file size is
297       unlimited.
298
299
300       --log-flush-frequency=5s       Maximum  number  of  seconds between log
301       flushes
302
303
304       --logtostderr=true      log to standard error instead of files
305
306
307       --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
308            Comma-separated  list  of  files  to check for machine-id. Use the
309       first one that exists.
310
311
312       --match-server-version=false       Require  server  version  to   match
313       client version
314
315
316       -n,  --namespace=""       If  present, the namespace scope for this CLI
317       request
318
319
320       --one-output=false      If true, only write logs to their native sever‐
321       ity level (vs also writing to each lower severity level
322
323
324       --password=""      Password for basic authentication to the API server
325
326
327       --profile="none"         Name   of   profile   to   capture.   One   of
328       (none|cpu|heap|goroutine|threadcreate|block|mutex)
329
330
331       --profile-output="profile.pprof"      Name of the  file  to  write  the
332       profile to
333
334
335       --referenced-reset-interval=0       Reset interval for referenced bytes
336       (container_referenced_bytes metric), number of measurement cycles after
337       which  referenced  bytes  are cleared, if set to 0 referenced bytes are
338       never cleared (default: 0)
339
340
341       --request-timeout="0"      The length of time to wait before giving  up
342       on  a  single  server  request. Non-zero values should contain a corre‐
343       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
344       out requests.
345
346
347       -s, --server=""      The address and port of the Kubernetes API server
348
349
350       --skip-headers=false       If  true,  avoid  header prefixes in the log
351       messages
352
353
354       --skip-log-headers=false      If true, avoid headers when  opening  log
355       files
356
357
358       --stderrthreshold=2      logs at or above this threshold go to stderr
359
360
361       --storage-driver-buffer-duration=1m0s      Writes in the storage driver
362       will be buffered for this duration, and committed  to  the  non  memory
363       backends as a single transaction
364
365
366       --storage-driver-db="cadvisor"      database name
367
368
369       --storage-driver-host="localhost:8086"      database host:port
370
371
372       --storage-driver-password="root"      database password
373
374
375       --storage-driver-secure=false      use secure connection with database
376
377
378       --storage-driver-table="stats"      table name
379
380
381       --storage-driver-user="root"      database username
382
383
384       --tls-server-name=""       Server  name  to  use for server certificate
385       validation. If it is not provided, the hostname  used  to  contact  the
386       server is used
387
388
389       --token=""      Bearer token for authentication to the API server
390
391
392       --update-machine-info-interval=5m0s       Interval between machine info
393       updates.
394
395
396       --user=""      The name of the kubeconfig user to use
397
398
399       --username=""      Username for basic authentication to the API server
400
401
402       -v, --v=0      number for the log level verbosity
403
404
405       --version=false      Print version information and quit
406
407
408       --vmodule=       comma-separated  list  of   pattern=N   settings   for
409       file-filtered logging
410
411
412       --warnings-as-errors=false      Treat warnings received from the server
413       as errors and exit with a non-zero exit code
414
415
416

EXAMPLE

418                # Delete a pod using the type and name specified in pod.json.
419                kubectl delete -f ./pod.json
420
421                # Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml.
422                kubectl delete -k dir
423
424                # Delete a pod based on the type and name in the JSON passed into stdin.
425                cat pod.json | kubectl delete -f -
426
427                # Delete pods and services with same names "baz" and "foo"
428                kubectl delete pod,service baz foo
429
430                # Delete pods and services with label name=myLabel.
431                kubectl delete pods,services -l name=myLabel
432
433                # Delete a pod with minimal delay
434                kubectl delete pod foo --now
435
436                # Force delete a pod on a dead node
437                kubectl delete pod foo --force
438
439                # Delete all pods
440                kubectl delete pods --all
441
442
443
444

SEE ALSO

446       kubectl(1),
447
448
449

HISTORY

451       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
452       com)  based  on the kubernetes source material, but hopefully they have
453       been automatically generated since!
454
455
456
457Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum