Performing Graceful Deletion
What Is Graceful Deletion?
When a user requests to delete a resource object that contains a pod (such as an RC or Deployment), if the resource object has requests being processed, the resource object is deleted after the requests are processed.
How to Use Graceful Deletion
You can run Kubernetes commands for graceful deletion. The kubectl delete command deletes resources by resource name or label. Example:
kubectl delete po rc-nginx-btv4j kubectl delete po -lapp=nginx-2
When Kubernetes instructs the node to run the docker stop command, Docker sends the system signal SIGTERM to the process whose PID is 1 in the container and waits for the applications in the container to stop. If the waiting time reaches the specified timeout (30s by default), Docker will send the system signal SIGKILL to forcibly kill the process.
- To download open source images, run the corresponding command. For example, to obtain the Nginx image, run the following command:
- To download the images that you have uploaded to SWR, perform the following operations:
- Log in to the SWR console.
- Choose My Images in the navigation pane and then click the image to be downloaded. The details page is displayed.
- Click the Pull/Push tab, and run the docker pull command to download the desired image as prompted.
The specified timeout can be overwritten by --grace-period flag. To forcibly delete resources, you need to specify --force flag and set the period to 0. If a pod is to be forcibly deleted, the scheduler will place a new pod on the node before the node releases the pod to be deleted, and the pod to be deleted will be evicted immediately.
The following example indicates that the pod is forcibly deleted immediately:
kubectl delete po rc-nginx-btv4j --grace-period=0 --force
When the delete command is run, the resource version is not checked. If an update operation is performed when the delete command is run, the update operation is deleted together with the resource.
Last Article: Setting Time Zone Synchronization
Next Article: Setting the Container Network Bandwidth Limit
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.