Deleting a ReplicaSet

In order to remove the ReplicaSet from the Kubernetes system, you can rely on the subcommand delete. When we fire delete to remove the resource, it removes the target objects forcefully:

$ time kubectl delete rs my-first-replicaset && kubectl get pod
replicaset.extensions "my-first-replicaset" deleted
real 0m2.492s
user 0m0.188s
sys 0m0.048s
NAME READY STATUS RESTARTS AGE
my-first-replicaset-8hg55 0/1 Terminating 0 53m
my-first-replicaset-b6kr2 1/1 Terminating 0 48m
my-first-replicaset-wtphz 0/1 Terminating 0 53m
my-first-replicaset-xcrws 1/1 Terminating 0 53m

We find that the response time is quite short and the effect is also instantaneous.

Removing the Pod under ReplicaSet
As we mentioned previously, it is impossible to scale down the ReplicaSet by deleting the Pod, because while a Pod is removed, the ReplicaSet is out of stable status: if the desired number of Pods is not met, and the controller manager will ask ReplicaSet to create another one. The concept is shown in the following commands:
// check ReplicaSet and the Pods
$ kubectl get rs,pod
NAME DESIRED CURRENT READY AGE
rs/my-first-replicaset 3 3 3 14s
NAME READY STATUS RESTARTS AGE
po/my-first-replicaset-bxf45 1/1 Running 0 14s
po/my-first-replicaset-r6wpx 1/1 Running 0 14s
po/my-first-replicaset-vt6fd 1/1 Running 0 14s

// remove certain Pod and check what happened
$ kubectl delete pod my-first-replicaset-bxf45
pod "my-first-replicaset-bxf45" deleted
$ kubectl get rs,pod
NAME DESIRED CURRENT READY AGE
rs/my-first-replicaset 3 3 3 2m
NAME READY STATUS RESTARTS AGE
po/my-first-replicaset-dvbpg 1/1 Running 0 6s
po/my-first-replicaset-r6wpx 1/1 Running 0 2m
po/my-first-replicaset-vt6fd 1/1 Running 0 2m

// check the event log as well
$ kubectl describe rs my-first-replicaset
(ignored)
:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 2m replicaset-controller Created pod: my-first-replicaset-bxf45
Normal SuccessfulCreate 2m replicaset-controller Created pod: my-first-replicaset-r6wpx
Normal SuccessfulCreate 2m replicaset-controller Created pod: my-first-replicaset-vt6fd
Normal SuccessfulCreate 37s replicaset-controller Created pod: my-first-replicaset-dvbpg
You will find that although the my-first-replicaset-bxf45 Pod is removed, the my-first-replicaset-dvbpg Pod is created automatically and attached to this ReplicaSet.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.144.48