How to Manage and View Pods: Deleting Pods and Replicas Explained

Why does K8S create a new pod automatically after deleting one?

View all pods

kubectl get pods -A -owide

Delete a pod

kubectl delete pod  -n 

Then, view all pods again and you will find a new pod has been created. This is because the number of replicas is defined in the deployment.yaml file, so you also need to delete the replicas.

kubectl get deployment -A

Delete replicas

kubectl delete deployment  -n 
view pods

After deleting the replicas, the corresponding pod will also be deleted.

Reason analysis: The number of replicas is set in the yaml file, so when a pod is deleted, a new pod will be created.

view pods

How to force delete a pod in k8s

kubectl get rc

If there is an rc, delete the rc first, then delete the pod.

If there is no rc, execute directly:

kubectl delete pod  --grace-period=0 --force -n