Skip to content

Commit 1f4ca9f

Browse files
authored
Merge pull request #31631 from tengqm/fix-gc-cascade
Fix the cascading deletion page
2 parents 7ef7a39 + d4f6e0b commit 1f4ca9f

File tree

1 file changed

+127
-126
lines changed

1 file changed

+127
-126
lines changed

content/en/docs/tasks/administer-cluster/use-cascading-deletion.md

Lines changed: 127 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ content_type: task
55

66
<!--overview-->
77

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)
910
to use in your cluster during {{<glossary_tooltip text="garbage collection" term_id="garbage-collection">}}.
1011

1112
## {{% heading "prerequisites" %}}
@@ -26,7 +27,7 @@ kubectl get pods -l app=nginx --output=yaml
2627

2728
The output has an `ownerReferences` field similar to this:
2829

29-
```
30+
```yaml
3031
apiVersion: v1
3132
...
3233
ownerReferences:
@@ -41,7 +42,7 @@ apiVersion: v1
4142

4243
## Use foreground cascading deletion {#use-foreground-cascading-deletion}
4344

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)
4546
to delete dependents of an object. You can switch to foreground cascading deletion
4647
using either `kubectl` or the Kubernetes API, depending on the Kubernetes
4748
version your cluster runs. {{<version-check>}}
@@ -64,9 +65,9 @@ kubectl delete deployment nginx-deployment --cascade=foreground
6465

6566
1. Start a local proxy session:
6667

67-
```shell
68-
kubectl proxy --port=8080
69-
```
68+
```shell
69+
kubectl proxy --port=8080
70+
```
7071

7172
1. Use `curl` to trigger deletion:
7273

@@ -80,19 +81,19 @@ kubectl delete deployment nginx-deployment --cascade=foreground
8081
like this:
8182

8283
```
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+
...
9697
```
9798

9899
{{% /tab %}}
@@ -104,9 +105,9 @@ For details, read the [documentation for your Kubernetes version](/docs/home/sup
104105

105106
1. Start a local proxy session:
106107

107-
```shell
108-
kubectl proxy --port=8080
109-
```
108+
```shell
109+
kubectl proxy --port=8080
110+
```
110111

111112
1. Use `curl` to trigger deletion:
112113

@@ -120,19 +121,19 @@ For details, read the [documentation for your Kubernetes version](/docs/home/sup
120121
like this:
121122

122123
```
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+
...
136137
```
137138
{{% /tab %}}
138139
{{</tabs>}}
@@ -165,32 +166,32 @@ kubectl delete deployment nginx-deployment --cascade=background
165166

166167
1. Start a local proxy session:
167168

168-
```shell
169-
kubectl proxy --port=8080
170-
```
169+
```shell
170+
kubectl proxy --port=8080
171+
```
171172

172173
1. Use `curl` to trigger deletion:
173174

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+
```
179180

180-
The output is similar to this:
181+
The output is similar to this:
181182

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+
```
194195
{{% /tab %}}
195196
{{% tab name="Versions prior to Kubernetes 1.20.x" %}}
196197
Kubernetes uses background cascading deletion by default, and does so
@@ -211,32 +212,32 @@ kubectl delete deployment nginx-deployment --cascade=true
211212

212213
1. Start a local proxy session:
213214

214-
```shell
215-
kubectl proxy --port=8080
216-
```
215+
```shell
216+
kubectl proxy --port=8080
217+
```
217218

218219
1. Use `curl` to trigger deletion:
219220

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+
```
225226

226-
The output is similar to this:
227+
The output is similar to this:
227228

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+
```
240241
{{% /tab %}}
241242
{{</tabs>}}
242243

@@ -264,33 +265,33 @@ kubectl delete deployment nginx-deployment --cascade=orphan
264265

265266
1. Start a local proxy session:
266267

267-
```shell
268-
kubectl proxy --port=8080
269-
```
268+
```shell
269+
kubectl proxy --port=8080
270+
```
270271

271272
1. Use `curl` to trigger deletion:
272273

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+
```
294295

295296
{{% /tab %}}
296297
{{% tab name="Versions prior to Kubernetes 1.20.x" %}}
@@ -309,33 +310,33 @@ kubectl delete deployment nginx-deployment --cascade=orphan
309310

310311
1. Start a local proxy session:
311312

312-
```shell
313-
kubectl proxy --port=8080
314-
```
313+
```shell
314+
kubectl proxy --port=8080
315+
```
315316

316317
1. Use `curl` to trigger deletion:
317318

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+
```
339340
{{% /tab %}}
340341
{{</tabs>}}
341342

@@ -349,4 +350,4 @@ kubectl get pods -l app=nginx
349350

350351
* Learn about [owners and dependents](/docs/concepts/overview/working-with-objects/owners-dependents/) in Kubernetes.
351352
* 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

Comments
 (0)