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

NAME

9       kubectl  delete  - Delete resources by file names, 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 file names, 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 argument may be
25       specified: file names, resources and names, or resources and label  se‐
26       lector.
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, the --grace-period flag 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
51       scheduler may place new pods on those nodes before  the  node  has  re‐
52       leased  those  resources  and  causing those pods to be evicted immedi‐
53       ately.
54
55
56       Note that the delete command does NOT do resource version checks, so if
57       someone submits an update to a resource right when you submit a delete,
58       their update will be lost along with the rest of the resource.
59
60
61       After a CustomResourceDefinition is deleted, invalidation of  discovery
62       cache may take up to 6 hours. If you don't want to wait, you might want
63       to run "kubectl api-resources" to refresh the discovery cache.
64
65
66

OPTIONS

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

OPTIONS INHERITED FROM PARENT COMMANDS

147       --as=""      Username to impersonate for the operation. User could be a
148       regular user or a service account in a namespace.
149
150
151       --as-group=[]       Group  to  impersonate for the operation, this flag
152       can be repeated to specify multiple groups.
153
154
155       --as-uid=""      UID to impersonate for the operation.
156
157
158       --azure-container-registry-config=""      Path to the  file  containing
159       Azure container registry configuration information.
160
161
162       --cache-dir="/builddir/.kube/cache"      Default cache directory
163
164
165       --certificate-authority=""      Path to a cert file for the certificate
166       authority
167
168
169       --client-certificate=""      Path to a client certificate file for TLS
170
171
172       --client-key=""      Path to a client key file for TLS
173
174
175       --cluster=""      The name of the kubeconfig cluster to use
176
177
178       --context=""      The name of the kubeconfig context to use
179
180
181       --disable-compression=false      If true, opt-out of response  compres‐
182       sion for all requests to the server
183
184
185       --insecure-skip-tls-verify=false      If true, the server's certificate
186       will not be checked for validity. This will make your HTTPS connections
187       insecure
188
189
190       --kubeconfig=""       Path  to  the  kubeconfig file to use for CLI re‐
191       quests.
192
193
194       --match-server-version=false       Require  server  version  to   match
195       client version
196
197
198       -n,  --namespace=""       If  present, the namespace scope for this CLI
199       request
200
201
202       --password=""      Password for basic authentication to the API server
203
204
205       --profile="none"        Name   of   profile   to   capture.   One    of
206       (none|cpu|heap|goroutine|threadcreate|block|mutex)
207
208
209       --profile-output="profile.pprof"       Name  of  the  file to write the
210       profile to
211
212
213       --request-timeout="0"      The length of time to wait before giving  up
214       on  a  single  server  request. Non-zero values should contain a corre‐
215       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
216       out requests.
217
218
219       -s, --server=""      The address and port of the Kubernetes API server
220
221
222       --tls-server-name=""       Server  name  to  use for server certificate
223       validation. If it is not provided, the hostname  used  to  contact  the
224       server is used
225
226
227       --token=""      Bearer token for authentication to the API server
228
229
230       --user=""      The name of the kubeconfig user to use
231
232
233       --username=""      Username for basic authentication to the API server
234
235
236       --version=false      Print version information and quit
237
238
239       --warnings-as-errors=false      Treat warnings received from the server
240       as errors and exit with a non-zero exit code
241
242
243

EXAMPLE

245                # Delete a pod using the type and name specified in pod.json
246                kubectl delete -f ./pod.json
247
248                # Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
249                kubectl delete -k dir
250
251                # Delete resources from all files that end with '.json' - i.e. expand wildcard characters in file names
252                kubectl delete -f '*.json'
253
254                # Delete a pod based on the type and name in the JSON passed into stdin
255                cat pod.json | kubectl delete -f -
256
257                # Delete pods and services with same names "baz" and "foo"
258                kubectl delete pod,service baz foo
259
260                # Delete pods and services with label name=myLabel
261                kubectl delete pods,services -l name=myLabel
262
263                # Delete a pod with minimal delay
264                kubectl delete pod foo --now
265
266                # Force delete a pod on a dead node
267                kubectl delete pod foo --force
268
269                # Delete all pods
270                kubectl delete pods --all
271
272
273
274

SEE ALSO

276       kubectl(1),
277
278
279

HISTORY

281       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
282       com)  based  on the kubernetes source material, but hopefully they have
283       been automatically generated since!
284
285
286
287Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum