Answers: <p>Shameless self-answer:</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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. </p>
  
  <p>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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-01-17T22:47:38.750Z
Answers: 2019-01-17T22:47:38.750Z
Answers: AnoE
Body: <p>What's the best way to change a statefulset (e.g., modify the ENV parameters, modify PVCs) in OpenShift? <code>oc edit statefulset xyz</code> only allows to change the scaling, nothing else.</p>
  
Tags: <openshift>
Title: How to change a statefulset in OpenShift?
UserDisplayName: AnoE
ThreadText: # How to change a statefulset in OpenShift?
  
  (Asked by: username_0 on 2018-11-14)
  
  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.
  
  **Tags:** openshift
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-01-17. Score: 2 | Accepted answer
  
  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.
  
  
  ---
  
  