<p>I was trying to resize persistent volumes associated with a stateful set today. I am using Azure Kubernetes service v1.26.6. The persistent voluem is created from a storage class of type &quot;default&quot;.</p>
<p>As per the official Kubernetes documentation at: <a href="https://kubernetes.io/blog/2022/05/05/volume-expansion-ga/" rel="nofollow noreferrer">https://kubernetes.io/blog/2022/05/05/volume-expansion-ga/</a>, it is now possible to expand the size of a persistent volume without any downtime, just by updating the spec field of the PVC of the stateful set and re-deploying the stateful set. However, I attempted the same today(i.e tried to redeploy an already deployed stateful set but with increased size for the PVC) and i ran into the usual error:</p>
<blockquote>
<p>Error: UPGRADE FAILED: cannot patch &quot;grafana-loki-querier&quot; with kind
StatefulSet: StatefulSet.apps &quot;grafana-loki-querier&quot; is invalid: spec:
Forbidden: updates to statefulset spec for fields other than
'replicas', 'ordinals', 'template', 'updateStrategy',
'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are
forbidden</p>
</blockquote>
<p>To overcome this error, I then followed the instructions at: <a href="https://www.giffgaff.io/tech/resizing-statefulset-persistent-volumes-with-zero-downtime" rel="nofollow noreferrer">https://www.giffgaff.io/tech/resizing-statefulset-persistent-volumes-with-zero-downtime</a> and was then finally able to successfully deploy the <strong>helm chart</strong> containing updated sizes for the resized PVC.</p>
<p><strong>Questions</strong></p>
<ul>
<li><p>Am I misunderstanding the official Kubernetes documentation that I have linked in the question?</p>
</li>
<li><p>I am curious. Technically, if the size of the PVC can be increased by editing the spec field in the PVC object directly(kubectl edit pvc), why is Kubernetes imposing a restriction to do the same by directly updating the size in the PVC manifest files ie. why cannot I increase the size of the PVC using a <strong>helm deployment</strong>?</p>
</li>
</ul>
<p>Why is the workflow not an integral part of Kubernetes deployments using Helm?</p>
<p>Why does it involve deleting the stateful set followed by recreation of the stateful set? What is the reason for the same?</p>
<p><a href="https://i.stack.imgur.com/MLT6T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MLT6T.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/Kehzj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kehzj.png" alt="enter image description here" /></a></p>

Kiran Hegde
<blockquote>
<blockquote>
<p>Questions -Am i misunderstanding the official Kubernetes documentation that i have linked in the question?</p>
</blockquote>
</blockquote>
<p>Not really, but you are only partially true.</p>
<p>Even if StorageClass supports resizing, Kubernetes doesn't support (yet) volume expansion through StatefulSets. Please refer to the official enhancement issue at <a href="https://github.com/kubernetes/enhancements/issues/661" rel="nofollow noreferrer">Support Volume Expansion Through StatefulSets</a>
and Kubernetes <a href="https://github.com/kubernetes/kubernetes/issues/68737" rel="nofollow noreferrer">StatefulSet: support resize pvc storage</a>.</p>
<h3>More Insights</h3>
<blockquote>
<p>Why is the workflow not an integral part of Kubernetes deployments using Helm?</p>
</blockquote>
<p>In this case, this has nothing to do with helm charts but actually with the Kubernetes controller involved in the application stack, as the controller is continuously monitoring the app and making the required changes as per its defined manifest and hence as mentioned in your workaround document you had to scale it to <code>0</code></p>
<p>Second, we had to delete the stateful state with the orphan strategy so that the actual pod ( working application ) does not get deleted and only the stateful set controller(kind) is deleted. Because of that, you are allowed to Update the PVC and then it gets resized only if resizing is supported and enabled on your storageClass-&gt;Storage Driver which seems the case.</p>
<blockquote>
<blockquote>
<p>Normally helm has quite a lot of flaws but in this case, it's not the culprit.😬</p>
</blockquote>
</blockquote>
