I have a custom Kubernetes Go operator that I want to be able to update a running instance/pod with zero downtime. ie I want to create a new pod and have it running before I delete the old pod.
What is the best way to do this?
At the moment I am doing this:
// 1. Create the new pod
err := r.client.Create(context.TODO(), pod)
// 2. Delete the old pod
err := r.client.Create(context.TODO(), &oldpod)
// 3. Loop until the new pod is no longer in the pending phaseThis works but of course the old pod is deleted before the new one is ready.
Ideally I want to swap the delete (step 2) with the wait loop so that the delete only happens if and when the new pod is in the PodSucceeded or PodRunning phase. When I do that I run into other issues (I think because the reconcile function gets called from the initial pod create and the replicas count becomes incorrect).