Replicaset query

Hello,

I created 5 PODs with lable as tier=frontend as below :

image

Then I create with a replicaset with same label and mentioned number of replicas to 3. Immediately 2 pods were terminated to maintain the number of pods to 3.

So my question is on what based the pods were seleted to maintain and to delete? Is it some random selection or is it based on any reason?

Also is there any way I can check pods those are being managed by a particular replicaset, other than matching the prefix of replicaset name?

Thanks
Ashish

Hi @06ashishrawat,

The ReplicaSet is defined with a selector that specifies how to identify Pods it can acquire, a number of replicas indicating how many Pods it should be maintaining, So if the ReplicaSet selector as tier=frontend will acquire the pods with the label tier=frontend and will fulfill its purpose by creating and deleting Pods as needed to reach the desired number.

Kindly check the following URL:

Hello @Ayman yes that concept I understand. My question was if I already have 5 pods with lables as tier=frontend and then I create replicaset with selector as tier=frontend and set number of replica to 3.

now on which bases replicaset will select 3 pods and delete 2 pods. Will it be a random selection or there will be some selection algo/logic behind it.

Thanks
Ashish

Hello, @06ashishrawat
I think it’s a random selection.

OK @Tej-Singh-Rana. Thanks for the calrification.