@@ -47,8 +47,7 @@ to delete dependents of an object. You can switch to foreground cascading deleti
47
47
using either ` kubectl ` or the Kubernetes API, depending on the Kubernetes
48
48
version your cluster runs. {{<version-check >}}
49
49
50
- {{<tabs name =" foreground_deletion " >}}
51
- {{% tab name="Kubernetes 1.20.x and later" %}}
50
+
52
51
You can delete objects using foreground cascading deletion using ` kubectl ` or the
53
52
Kubernetes API.
54
53
@@ -96,56 +95,13 @@ kubectl delete deployment nginx-deployment --cascade=foreground
96
95
...
97
96
```
98
97
99
- {{% /tab %}}
100
- {{% tab name="Versions prior to Kubernetes 1.20.x" %}}
101
- You can delete objects using foreground cascading deletion by calling the
102
- Kubernetes API.
103
-
104
- For details, read the [ documentation for your Kubernetes version] ( /docs/home/supported-doc-versions/ ) .
105
-
106
- 1 . Start a local proxy session:
107
-
108
- ``` shell
109
- kubectl proxy --port=8080
110
- ```
111
-
112
- 1 . Use ` curl ` to trigger deletion:
113
-
114
- ``` shell
115
- curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
116
- -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Foreground"}' \
117
- -H " Content-Type: application/json"
118
- ```
119
-
120
- The output contains a ` foregroundDeletion ` {{<glossary_tooltip text="finalizer" term_id="finalizer">}}
121
- like this:
122
-
123
- ```
124
- "kind": "Deployment",
125
- "apiVersion": "apps/v1",
126
- "metadata": {
127
- "name": "nginx-deployment",
128
- "namespace": "default",
129
- "uid": "d1ce1b02-cae8-4288-8a53-30e84d8fa505",
130
- "resourceVersion": "1363097",
131
- "creationTimestamp": "2021-07-08T20:24:37Z",
132
- "deletionTimestamp": "2021-07-08T20:27:39Z",
133
- "finalizers": [
134
- "foregroundDeletion"
135
- ]
136
- ...
137
- ```
138
- {{% /tab %}}
139
- {{</tabs >}}
140
98
141
99
## Use background cascading deletion {#use-background-cascading-deletion}
142
100
143
101
1 . [ Create a sample Deployment] ( /docs/tasks/run-application/run-stateless-application-deployment/#creating-and-exploring-an-nginx-deployment ) .
144
102
1 . Use either ` kubectl ` or the Kubernetes API to delete the Deployment,
145
103
depending on the Kubernetes version your cluster runs. {{<version-check >}}
146
104
147
- {{<tabs name =" background_deletion " >}}
148
- {{% tab name="Kubernetes version 1.20.x and later" %}}
149
105
150
106
You can delete objects using background cascading deletion using ` kubectl `
151
107
or the Kubernetes API.
@@ -192,54 +148,6 @@ kubectl delete deployment nginx-deployment --cascade=background
192
148
"uid": "cc9eefb9-2d49-4445-b1c1-d261c9396456"
193
149
}
194
150
```
195
- {{% /tab %}}
196
- {{% tab name="Versions prior to Kubernetes 1.20.x" %}}
197
- Kubernetes uses background cascading deletion by default, and does so
198
- even if you run the following commands without the ` --cascade ` flag or the
199
- ` propagationPolicy: Background ` argument.
200
-
201
- For details, read the [ documentation for your Kubernetes version] ( /docs/home/supported-doc-versions/ ) .
202
-
203
- ** Using kubectl**
204
-
205
- Run the following command:
206
-
207
- ``` shell
208
- kubectl delete deployment nginx-deployment --cascade=true
209
- ```
210
-
211
- ** Using the Kubernetes API**
212
-
213
- 1 . Start a local proxy session:
214
-
215
- ``` shell
216
- kubectl proxy --port=8080
217
- ```
218
-
219
- 1 . Use ` curl ` to trigger deletion:
220
-
221
- ``` shell
222
- curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
223
- -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Background"}' \
224
- -H " Content-Type: application/json"
225
- ```
226
-
227
- The output is similar to this:
228
-
229
- ```
230
- "kind": "Status",
231
- "apiVersion": "v1",
232
- ...
233
- "status": "Success",
234
- "details": {
235
- "name": "nginx-deployment",
236
- "group": "apps",
237
- "kind": "deployments",
238
- "uid": "cc9eefb9-2d49-4445-b1c1-d261c9396456"
239
- }
240
- ```
241
- {{% /tab %}}
242
- {{</tabs >}}
243
151
244
152
245
153
## Delete owner objects and orphan dependents {#set-orphan-deletion-policy}
@@ -250,8 +158,6 @@ dependent objects. You can make Kubernetes *orphan* these dependents using
250
158
` kubectl ` or the Kubernetes API, depending on the Kubernetes version your
251
159
cluster runs. {{<version-check >}}
252
160
253
- {{<tabs name =" orphan_objects " >}}
254
- {{% tab name="Kubernetes version 1.20.x and later" %}}
255
161
256
162
** Using kubectl**
257
163
@@ -293,52 +199,6 @@ kubectl delete deployment nginx-deployment --cascade=orphan
293
199
...
294
200
```
295
201
296
- {{% /tab %}}
297
- {{% tab name="Versions prior to Kubernetes 1.20.x" %}}
298
-
299
- For details, read the [ documentation for your Kubernetes version] ( /docs/home/supported-doc-versions/ ) .
300
-
301
- ** Using kubectl**
302
-
303
- Run the following command:
304
-
305
- ``` shell
306
- kubectl delete deployment nginx-deployment --cascade=orphan
307
- ```
308
-
309
- ** Using the Kubernetes API**
310
-
311
- 1 . Start a local proxy session:
312
-
313
- ``` shell
314
- kubectl proxy --port=8080
315
- ```
316
-
317
- 1 . Use ` curl ` to trigger deletion:
318
-
319
- ``` shell
320
- curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
321
- -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Orphan"}' \
322
- -H " Content-Type: application/json"
323
- ```
324
-
325
- The output contains ` orphan ` in the ` finalizers ` field, similar to this:
326
-
327
- ```
328
- "kind": "Deployment",
329
- "apiVersion": "apps/v1",
330
- "namespace": "default",
331
- "uid": "6f577034-42a0-479d-be21-78018c466f1f",
332
- "creationTimestamp": "2021-07-09T16:46:37Z",
333
- "deletionTimestamp": "2021-07-09T16:47:08Z",
334
- "deletionGracePeriodSeconds": 0,
335
- "finalizers": [
336
- "orphan"
337
- ],
338
- ...
339
- ```
340
- {{% /tab %}}
341
- {{</tabs >}}
342
202
343
203
You can check that the Pods managed by the Deployment are still running:
344
204
0 commit comments