Orphan and Rejoin pets to a Kubernetes PetSet

8/11/2016

The PetSet documentation says:

Updating an existing Pet Set is currently a manual process, meaning you either need to deploy a new Pet Set with the new image version, or orphan Pets one by one, update their image, and join them back to the cluster.

But I don't see any documentation on how to actually do that. How would one orphan a pet and then have it rejoin?

Also, suppose I oprhan my pets one-by-one and then rejoin them to the cluster. The PetSet manifest itself isn't changed, so what happens if a pod crashes? Will the petSet restart it with the previous, old image?

-- Oliver Dain
kubernetes

2 Answers

11/7/2016

I was just facing the exact same issue and I have to say that I don't agree with the selected answer.


First of all, removing a petset will remove all related pods.
According to the docs it will simply not remove the pv/pvcs.

Deleting and/or scaling a PetSet down will not delete the volumes associated with the PetSet. This is done to ensure safety first, your data is more valuable than an auto purge of all related PetSet resources. Deleting the Persistent Volume Claims will result in a deletion of the associated volumes.

In order to update a PetSet, you need to first delete the old one using --cascade=false.
This will remove the PetSet but keep everything else, including the running pods.

You can now re-deploy the updated PetSet and start removing pods one at a time.
The pods will be re-created using the new PetSet template.

-- George Antoniadis
Source: StackOverflow

8/11/2016

Sorry this is not clear. As mentioned the easiest way to update the petset is to deploy another one.

The word "orphan" is misleading in this context because it's used elsewhere to mean change labels/selectors. The PetSet works on the concept of identity, if there are N pods with a given identity (i.e network + storage + ordinal) it won't create any more. You can't have 2 pets with the same identity for the obvious reasons, meaning if you "orphan" pet-1, the petset controller will not create another pet-1, because that means 2 pods get the same DNS name.

To perform an inplace upgrade without losing quorum you will have to orphan each pet from the cluster not the petset. I.e if you have a 5 member zookeeper cluster, update the configs of 4 members to think they now have only 4 members, upgrade 1, then updated the 4 members to include the new one.

Also, suppose I oprhan my pets one-by-one and then rejoin them to the cluster. The PetSet manifest itself isn't changed, so what happens if a pod crashes? Will the petSet restart it with the previous, old image?

You can recreate the petset with the new image. Deleting it will not delete pets (http://kubernetes.io/docs/user-guide/petset/#alpha-limitations), and creating it will not recreate as long as the expected identities exist.

kubectl rolling-update for petset is planned in the next release (https://github.com/kubernetes/kubernetes/issues/28706).

-- Prashanth B
Source: StackOverflow