@@ -5,7 +5,8 @@ content_type: task
5
5
6
6
<!-- overview-->
7
7
8
- This page shows you how to specify the type of [ cascading deletion] ( /docs/concepts/workloads/controllers/garbage-collection/#cascading-deletion )
8
+ This page shows you how to specify the type of
9
+ [ cascading deletion] ( /docs/concepts/architecture/garbage-collection/#cascading-deletion )
9
10
to use in your cluster during {{<glossary_tooltip text="garbage collection" term_id="garbage-collection">}}.
10
11
11
12
## {{% heading "prerequisites" %}}
@@ -26,7 +27,7 @@ kubectl get pods -l app=nginx --output=yaml
26
27
27
28
The output has an ` ownerReferences ` field similar to this:
28
29
29
- ```
30
+ ``` yaml
30
31
apiVersion : v1
31
32
...
32
33
ownerReferences :
@@ -41,7 +42,7 @@ apiVersion: v1
41
42
42
43
## Use foreground cascading deletion {#use-foreground-cascading-deletion}
43
44
44
- By default, Kubernetes uses [ background cascading deletion] ( /docs/concepts/workloads/controllers /garbage-collection/#background-deletion )
45
+ By default, Kubernetes uses [ background cascading deletion] ( /docs/concepts/architecture /garbage-collection/#background-deletion )
45
46
to delete dependents of an object. You can switch to foreground cascading deletion
46
47
using either ` kubectl ` or the Kubernetes API, depending on the Kubernetes
47
48
version your cluster runs. {{<version-check >}}
@@ -64,9 +65,9 @@ kubectl delete deployment nginx-deployment --cascade=foreground
64
65
65
66
1 . Start a local proxy session:
66
67
67
- ``` shell
68
- kubectl proxy --port=8080
69
- ```
68
+ ``` shell
69
+ kubectl proxy --port=8080
70
+ ```
70
71
71
72
1 . Use ` curl ` to trigger deletion:
72
73
@@ -80,19 +81,19 @@ kubectl delete deployment nginx-deployment --cascade=foreground
80
81
like this:
81
82
82
83
```
83
- "kind": "Deployment",
84
- "apiVersion": "apps/v1",
85
- "metadata": {
86
- "name": "nginx-deployment",
87
- "namespace": "default",
88
- "uid": "d1ce1b02-cae8-4288-8a53-30e84d8fa505",
89
- "resourceVersion": "1363097",
90
- "creationTimestamp": "2021-07-08T20:24:37Z",
91
- "deletionTimestamp": "2021-07-08T20:27:39Z",
92
- "finalizers": [
93
- "foregroundDeletion"
94
- ]
95
- ...
84
+ "kind": "Deployment",
85
+ "apiVersion": "apps/v1",
86
+ "metadata": {
87
+ "name": "nginx-deployment",
88
+ "namespace": "default",
89
+ "uid": "d1ce1b02-cae8-4288-8a53-30e84d8fa505",
90
+ "resourceVersion": "1363097",
91
+ "creationTimestamp": "2021-07-08T20:24:37Z",
92
+ "deletionTimestamp": "2021-07-08T20:27:39Z",
93
+ "finalizers": [
94
+ "foregroundDeletion"
95
+ ]
96
+ ...
96
97
```
97
98
98
99
{{% /tab %}}
@@ -104,9 +105,9 @@ For details, read the [documentation for your Kubernetes version](/docs/home/sup
104
105
105
106
1 . Start a local proxy session:
106
107
107
- ```shell
108
- kubectl proxy --port=8080
109
- ```
108
+ ``` shell
109
+ kubectl proxy --port=8080
110
+ ```
110
111
111
112
1 . Use ` curl ` to trigger deletion:
112
113
@@ -120,19 +121,19 @@ For details, read the [documentation for your Kubernetes version](/docs/home/sup
120
121
like this:
121
122
122
123
```
123
- "kind": "Deployment",
124
- "apiVersion": "apps/v1",
125
- "metadata": {
126
- "name": "nginx-deployment",
127
- "namespace": "default",
128
- "uid": "d1ce1b02-cae8-4288-8a53-30e84d8fa505",
129
- "resourceVersion": "1363097",
130
- "creationTimestamp": "2021-07-08T20:24:37Z",
131
- "deletionTimestamp": "2021-07-08T20:27:39Z",
132
- "finalizers": [
133
- "foregroundDeletion"
134
- ]
135
- ...
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
+ ...
136
137
```
137
138
{{% /tab %}}
138
139
{{</tabs >}}
@@ -165,32 +166,32 @@ kubectl delete deployment nginx-deployment --cascade=background
165
166
166
167
1 . Start a local proxy session:
167
168
168
- ``` shell
169
- kubectl proxy --port=8080
170
- ```
169
+ ``` shell
170
+ kubectl proxy --port=8080
171
+ ```
171
172
172
173
1 . Use ` curl ` to trigger deletion:
173
174
174
- ` ` ` shell
175
- curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
176
- -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Background"}' \
177
- -H " Content-Type: application/json"
178
- ` ` `
175
+ ``` shell
176
+ curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
177
+ -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Background"}' \
178
+ -H " Content-Type: application/json"
179
+ ```
179
180
180
- The output is similar to this:
181
+ The output is similar to this:
181
182
182
- ```
183
- " kind" : " Status" ,
184
- " apiVersion" : " v1" ,
185
- ...
186
- " status" : " Success" ,
187
- " details" : {
188
- " name" : " nginx-deployment" ,
189
- " group" : " apps" ,
190
- " kind" : " deployments" ,
191
- " uid" : " cc9eefb9-2d49-4445-b1c1-d261c9396456"
192
- }
193
- ```
183
+ ```
184
+ "kind": "Status",
185
+ "apiVersion": "v1",
186
+ ...
187
+ "status": "Success",
188
+ "details": {
189
+ "name": "nginx-deployment",
190
+ "group": "apps",
191
+ "kind": "deployments",
192
+ "uid": "cc9eefb9-2d49-4445-b1c1-d261c9396456"
193
+ }
194
+ ```
194
195
{{% /tab %}}
195
196
{{% tab name="Versions prior to Kubernetes 1.20.x" %}}
196
197
Kubernetes uses background cascading deletion by default, and does so
@@ -211,32 +212,32 @@ kubectl delete deployment nginx-deployment --cascade=true
211
212
212
213
1 . Start a local proxy session:
213
214
214
- ` ` ` shell
215
- kubectl proxy --port=8080
216
- ` ` `
215
+ ``` shell
216
+ kubectl proxy --port=8080
217
+ ```
217
218
218
219
1 . Use ` curl ` to trigger deletion:
219
220
220
- ` ` ` shell
221
- curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
222
- -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Background"}' \
223
- -H " Content-Type: application/json"
224
- ` ` `
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
+ ```
225
226
226
- The output is similar to this:
227
+ The output is similar to this:
227
228
228
- ` ` `
229
- " kind" : " Status" ,
230
- " apiVersion" : " v1" ,
231
- ...
232
- " status" : " Success" ,
233
- " details" : {
234
- " name" : " nginx-deployment" ,
235
- " group" : " apps" ,
236
- " kind" : " deployments" ,
237
- " uid" : " cc9eefb9-2d49-4445-b1c1-d261c9396456"
238
- }
239
- ` ` `
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
+ ```
240
241
{{% /tab %}}
241
242
{{</tabs >}}
242
243
@@ -264,33 +265,33 @@ kubectl delete deployment nginx-deployment --cascade=orphan
264
265
265
266
1 . Start a local proxy session:
266
267
267
- ` ` ` shell
268
- kubectl proxy --port=8080
269
- ` ` `
268
+ ``` shell
269
+ kubectl proxy --port=8080
270
+ ```
270
271
271
272
1 . Use ` curl ` to trigger deletion:
272
273
273
- ` ` ` shell
274
- curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
275
- -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Orphan"}' \
276
- -H " Content-Type: application/json"
277
- ` ` `
278
-
279
- The output contains ` orphan` in the ` finalizers` field, similar to this:
280
-
281
- ` ` `
282
- " kind" : " Deployment" ,
283
- " apiVersion" : " apps/v1" ,
284
- " namespace" : " default" ,
285
- " uid" : " 6f577034-42a0-479d-be21-78018c466f1f" ,
286
- " creationTimestamp" : " 2021-07-09T16:46:37Z" ,
287
- " deletionTimestamp" : " 2021-07-09T16:47:08Z" ,
288
- " deletionGracePeriodSeconds" : 0,
289
- " finalizers" : [
290
- " orphan"
291
- ],
292
- ...
293
- ` ` `
274
+ ``` shell
275
+ curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
276
+ -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Orphan"}' \
277
+ -H " Content-Type: application/json"
278
+ ```
279
+
280
+ The output contains ` orphan ` in the ` finalizers ` field, similar to this:
281
+
282
+ ```
283
+ "kind": "Deployment",
284
+ "apiVersion": "apps/v1",
285
+ "namespace": "default",
286
+ "uid": "6f577034-42a0-479d-be21-78018c466f1f",
287
+ "creationTimestamp": "2021-07-09T16:46:37Z",
288
+ "deletionTimestamp": "2021-07-09T16:47:08Z",
289
+ "deletionGracePeriodSeconds": 0,
290
+ "finalizers": [
291
+ "orphan"
292
+ ],
293
+ ...
294
+ ```
294
295
295
296
{{% /tab %}}
296
297
{{% tab name="Versions prior to Kubernetes 1.20.x" %}}
@@ -309,33 +310,33 @@ kubectl delete deployment nginx-deployment --cascade=orphan
309
310
310
311
1 . Start a local proxy session:
311
312
312
- ` ` ` shell
313
- kubectl proxy --port=8080
314
- ` ` `
313
+ ``` shell
314
+ kubectl proxy --port=8080
315
+ ```
315
316
316
317
1 . Use ` curl ` to trigger deletion:
317
318
318
- ` ` ` shell
319
- curl -X DELETE localhost:8080/apis/apps/v1/namespaces/default/deployments/nginx-deployment \
320
- -d ' {"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Orphan"}' \
321
- -H " Content-Type: application/json"
322
- ` ` `
323
-
324
- The output contains ` orphan` in the ` finalizers` field, similar to this:
325
-
326
- ` ` `
327
- " kind" : " Deployment" ,
328
- " apiVersion" : " apps/v1" ,
329
- " namespace" : " default" ,
330
- " uid" : " 6f577034-42a0-479d-be21-78018c466f1f" ,
331
- " creationTimestamp" : " 2021-07-09T16:46:37Z" ,
332
- " deletionTimestamp" : " 2021-07-09T16:47:08Z" ,
333
- " deletionGracePeriodSeconds" : 0,
334
- " finalizers" : [
335
- " orphan"
336
- ],
337
- ...
338
- ` ` `
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
+ ```
339
340
{{% /tab %}}
340
341
{{</tabs >}}
341
342
@@ -349,4 +350,4 @@ kubectl get pods -l app=nginx
349
350
350
351
* Learn about [ owners and dependents] ( /docs/concepts/overview/working-with-objects/owners-dependents/ ) in Kubernetes.
351
352
* Learn about Kubernetes [ finalizers] ( /docs/concepts/overview/working-with-objects/finalizers/ ) .
352
- * Learn about [garbage collection](/docs/concepts/workloads/controllers /garbage-collection/).
353
+ * Learn about [ garbage collection] ( /docs/concepts/architecture /garbage-collection/ ) .
0 commit comments