title: How to change PVC size for statefulset with helm chart for new releases and preserve value for existing releases
body: <p>It is known that PVC resize for existing statefulsets is not possible yet <a href="https://github.com/kubernetes/kubernetes/issues/68737" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/68737</a></p>
  <p>Now, I have a helm chart with a statefulset and a PVC with 1GB size. When upgrading existing releases, I want to keep the existing value for the volume size, 1GB.</p>
  <p>When installing new releases, I want to change the default to, let's say, 10GB.</p>
  <p>How can I achieve this with the same chart, and only with default values (without providing custom values at install time) ?</p>
  <p>I tried with:</p>
  <pre><code>  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes: [&quot;ReadWriteOnce&quot;]
        resources:
          requests:
  {{- if .Release.IsInstall }}
            storage: {{ .Values.storage.size }}
  {{- end }}
  </code></pre>
  <p>which works for scratch installs, but then for an upgrade, the &quot;storage&quot; attribute is removed by helm and I am back to the same error:</p>
  <pre><code>Error: StatefulSet.apps &quot;test&quot; is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden
  </code></pre>
  <p>Is there a way to get/preserve the previous applied value from inside the helm template ?</p>
  <p>Note that I'm on helm v2.</p>
  <p>Scenario:</p>
  <ul>
  <li>I have a chart with versions: 1.0.0, 1.0.1</li>
  <li>For version 1.0.0 .Values.storage.size is 1GB</li>
  <li>For version 1.0.1 .Values.storage.size is 10GB</li>
  <li>I have an existing release, A, with chart version 1.0.0, so volume size 1GB</li>
  <li>With only default values defined in values.yaml, I want to be able to:
  <ul>
  <li>upgrade release A from chart version 1.0.0 to 1.0.1 while preserving the volume size (1GB)</li>
  <li>install from scratch release B, with chart version 1.0.1, with volume size 10</li>
  </ul>
  </li>
  </ul>