StatefulSet update: recreate THEN delete pods

nurxg

The Kubernetes StatefulSet RollingUpdate strategy deletes and recreates each Pod in order. I am interested in updating a StatefulSet by recreating a pod and then deleting the old Pod (note the reversal), one-by-one.

This is interesting to me because:

  1. There is no reduction in the number of Ready Pods. I understand this is how a normal Deployment update works too (i.e. a Pod is only deleted after the new Pod replacing it is Ready).
  2. More importantly, it allows me to perform application-specific live migration during my StatefulSet upgrade. I would like to "migrate" data from (old) pod-i to (new) pod-i before (old) pod-i is terminated (I would implement this in (new) pod-i readiness logic).

Is such an update strategy possible?

Dharma Bellamkonda

This is inherently possible with Deployments, but not StatefulSets. StatefulSets are used when you care strongly about an exact number of replicas with well known names. Deployments are used for more elastic workloads.

You may be able to accomplish your goal by using multiple StatefulSets- e.g. instead of a StatefulSet of 3 replicas, use 3 StatefulSets of 1 replica each. Then deploy an additional StatefulSet for your data migration before removing one of the previous ones.

Alternatively, this may be a use case for an Operator to manage the application.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to delete and recreate pods using yaml file in kubernetes

Ping pods of a statefulset via DNS

Recreate Pod managed by a StatefulSet with a fresh PersistentVolume

Configure starting index of StatefulSet's pods in Kubernetes

How to expose the scale of a deployment or statefulset to the pods in it?

Java: Delete and recreate object

Recreate Delete key functionality

Configure the starting index of pods being created by a StatefulSet in kubernetes

Pods in StatefulSet still terminating after the old liveness probe time

Stop all Pods in a StatefulSet before scaling it up or down

Pods in a statefulset and headless service do not get the right dns records

Can not delete pods in Kubernetes

Github usage : delete and recreate a fork?

pods still there when run kubectl delete pods

delete pods forcefully kubernetes API

How to delete and recreate db manually in migrations?

Delete a worksheet and recreate with the same sheet name

How to update pods to Swift 3.0

If I declare 2 replicas of PostgreSQL StatefulSet pods in k8s, are they the same database or they just share the volume?

Is a Kubernetes StatefulSet the right answer if all we need is a consistent identifier for each Pod in a group of identical Pods?

Kubernetes multiple pvc with statefulset for each pod vs single pvc for all pods?

How to recreate a database on an Android Application Update?

delete Kubernetes persistent volume from statefulset after scale down

Delete pods using kubectl containing a substring

Command to delete all pods in all kubernetes namespaces

Simple way to delete existing pods from Python

How to delete replication controller and its pods in kubernetes?

How Do I Delete Orphan Kubernetes Pods

Kubernetes:delete PODs/services/Configmaps based on age