What's the best way to change a statefulset (e.g., modify the ENV parameters, modify PVCs) in OpenShift? oc edit statefulset xyz only allows to change the scaling, nothing else.

1 Answer 1


Shameless self-answer:

So it turns out the only way to edit the statefulset, and this is by design, is to delete it and recreate it with the new values.

Doing that does not delete or stop the pods or the the PVCs - those will re-attach to the new statefulset spun up later, so you won't lose anything. N.B.: you can delete the pods, and the PVCs will still stick around. When the pods belonging to this statefulset restart later, they will re-attach to the PVCs.

There is a discussion on one of the OpenShift/Kubernetes task trackers (which I cannot find anymore) that explains the rationale: in contrast with stateless Deployments, where OpenShift can simply scale up a new set of pods, then scale down the old one, while routing traffic to the new one, this is not easily possible with statefulsets, since those have persistent PVCs, so there usually is a very defined number of pods that can/should run at a time.

So, if OpenShift would do an upgrade for you, due to an edit, it would need to decide how to do that (spawn up new pods parallel to the old one would require spinning up PVCs which may wreak havoc with your quota; replacing them in-place could wreak havoc if your pods need to talk to each other to synchronize). Hence, they require you to do this on your own. For example, you can decide to delete and recreate the statefulset, then delete one of the pods after the other; they will be automatically recreated immediately, as usual. You can then wait until the next pod has reached a state where it is synced with the other ones (in whatever way your software does it), then delete the next one etc., until you have upgraded them all.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.