...

/

Operating ReplicaSets

Operating ReplicaSets

Explore the operating procedure of ReplicaSets to witness its self-healing property in action.

Deleting ReplicaSets

As you might have guessed, both the ReplicaSet and everything it created (the Pods) would disappear with the kubectl delete -f go-demo-2.yml command.

However, since ReplicaSets and Pods are loosely coupled objects with matching labels, we can remove one without deleting the other.

We can, for example, remove the ReplicaSet we created while leaving the two Pods intact.

Press + to interact
kubectl delete -f go-demo-2.yml --cascade=orphan

We use the --cascade=orphan argument to prevent Kubernetes from removing all the downstream objects. As a result, we get the confirmation "go-demo-2" deleted.

Let’s confirm it is removed from the system:

Press + to interact
kubectl get rs

As expected, the output no resources were found in default namespace..

If --cascade=orphan indeed prevents Kubernetes from removing the downstream objects, the Pods should continue running in the cluster. Let’s confirm the assumption:

Press + to interact
kubectl get pods

The output is as follows:

Press + to interact
NAME READY STATUS RESTARTS AGE
go-demo-2-md5xp 2/2 Running 0 9m
go-demo-2-vnmf7 2/2 Running 0 9m

The two Pods created by the ReplicaSet are indeed still running in the cluster even though we removed the ReplicaSet.

The Pods that are currently running in the cluster do not have any relation with the ReplicaSet we created earlier. We deleted the ReplicaSet, and the Pods are still there.

Knowing that the ReplicaSet uses labels to decide whether the ...

Access this course and 1400+ top-rated courses and projects.