How to Delete all Pods in a ReplicaSet

I recently got into the Cloud Native Foundations Scholarship Program by Udacity, and with that, my day-to-day interaction with Kubernetes has increased. The exposure is good because I am learning Kubernetes and patching problems and sharing some tricks to solve my problems here.

One of them is to delete all pods in a ReplicaSet. I went through many StackOverflow questions with one-line finalizers that would do the job instantly, but it was all trial and error with 20 commands to find the one. In addition to that, pasting random finalizers that you don’t understand on the terminal is not recommended. Also, even if I am a massive fan of Googling stuff out, I get tired of Googling the same queries 10 times.

Setting up MongoDB Cluster and Replica-Set

Database Replication

Database replication is a process in which we run a set of database instances that maintain the same datasets and it provides redundancy and promises high availability of database servers. In case your one database falls down then you still will be able to use the other available database from the cluster and have the same datasets that you had in your previous replica. 

In this post, I am going to demonstrate the replication setup in MongoDB. If you're using some other database you might need to check if your database supports replication or not.