Kubernetes controller deletion strategy

1) General

There are 3 modes for deleting the Kubernetes controller:
a. Foreground:
Before deleting the controller, delete the resource objects managed by the controller.
b. Background:
After the controller is deleted, the resource objects managed by the controller are deleted by the GC in the background.
c. Orphan:
Only delete the controller, not the resource objects managed by the controller.


2) Rest api format (take the Deployment controller as an example):

a. Only delete the controller (corresponding to ReplicaSet and Pod not deleted)

DELETE /apis/apps/v1/namespaces/{namespace}/deployments/{name}
{
“Kind”: “DeleteOptions”,
“apiVersion”: “v1”,
“propagationPolicy”: “Orphan”
}

b. Front-end cascade delete (delete in the order of Pod->ReplicaSet->Deployment)

DELETE /apis/apps/v1/namespaces/{namespace}/deployments/{name}
{
“kind”: “DeleteOptions”,
“apiVersion”: “v1”,
“propagationPolicy”: “Foreground”
}

c. Background cascading deletion (delete in the order of Deployment->ReplicaSet->Pod)

DELETE /apis/apps/v1/namespaces/{namespace}/deployments/{name}
{
“kind”: “DeleteOptions”,
“apiVersion”: “v1”,
“propagationPolicy”: “Background”
}


3) Examples:

a, Orphan mode example

The mode specified in the request body of the delete request is Orphan:
{ "Kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Orphan" } Found: The pod object managed by the controller has not been deleted




Insert picture description here

Insert picture description here

b. Background mode example

Use kubectl to delete the controller, check the specific command details, and find that it is in Background mode:
-bash-4.2# kubectl delete ds nginx-ingress-controller -n ingress-nginx -v 10

I0730 11:54:08.751432 22493 loader.go:359] Config loaded from file: /root/.kube/config
I0730 11:54:08.752544 22493 cached_discovery.go:114] returning cached discovery info from /root/.kube/cache/discovery/192.168.35.75_16443/servergroups.json
I0730 11:54:08.753276 22493 cached_discovery.go:71] returning cached discovery info from /root/.kube/cache/discovery/192.168.35.75_16443/authorization.k8s.io/v1/serverresources.json
I0730 11:54:08.753301 22493 cached_discovery.go:71] returning cached discovery info from /root/.kube/cache/discovery/192.168.35.75_16443/metrics.k8s.io/v1beta1/serverresources.json



I0730 11:54:08.794908 22493 request.go:947] Request Body: {“propagationPolicy”:“Background”}
I0730 11:54:08.795008 22493 round_trippers.go:419] curl -k -v -XDELETE -H “Accept: application/json” -H “Content-Type: application/json” -H “User-Agent: kubectl/v1.15.1 (linux/amd64) kubernetes/4485c6f” ‘https://192.168.35.75:16443/apis/extensions/v1beta1/namespaces/ingress-nginx/daemonsets/nginx-ingress-controller’
I0730 11:54:08.823891 22493 round_trippers.go:438] DELETE https://192.168.35.75:16443/apis/extensions/v1beta1/namespaces/ingress-nginx/daemonsets/nginx-ingress-controller 200 OK in 28 milliseconds
I0730 11:54:08.823918 22493 round_trippers.go:444] Response Headers:
I0730 11:54:08.823931 22493 round_trippers.go:447] Content-Type: application/json
I0730 11:54:08.823939 22493 round_trippers.go:447] Content-Length: 201
I0730 11:54:08.823947 22493 round_trippers.go:447] Date: Tue, 30 Jul 2019 03:54:08 GMT
I0730 11:54:08.823983 22493 request.go:947] Response Body: {“kind”:“Status”,“apiVersion”:“v1”,“metadata”:{},“status”:“Success”,“details”:{“name”:“nginx-ingress-controller”,“group”:“extensions”,“kind”:“daemonsets”,“uid”:“2918e9da-70d9-4752-bdd2-a26c1dea607e”}}
daemonset.extensions “nginx-ingress-controller” deleted

Guess you like

Origin blog.csdn.net/nangonghen/article/details/102255334