Add additional volumeClaimTemplate to statefulSet

9/25/2018

We are using Kubernetes 1.10.1

I'm having a statefulset which has a single volumeClaim attached.

I would like to add an additional volumeClaim since resizing of an existing PV is still in beta and also not available in Kubernetes 1.10.

My change would basically just add an additional PVC (and of course also mount it which is not mentioned here):

*** 1,10 ****
--- 1,19 ----
    volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 100Gi
 +   - metadata:
 +       name: data2
 +     spec:
 +       accessModes:
 +       - ReadWriteOnce
 +       resources:
 +         requests:
 +           storage: 100Gi

As result I get an error:

Error: UPGRADE FAILED: StatefulSet.apps "my-app" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden.

Shouldn't at least adding additional PVCs be supported as long the existing ones are not being touched? Am I missing something here? I haven't found anything related to this in the documentation.

-- mat1010
kubernetes
kubernetes-statefulset
statefulset

1 Answer

9/25/2018

I don't know if there's any rationale on the design but the only reason why you would not want to update the storage template on a StatefulSet would be the stability of your application overall.

In any case, I agree that this should be allowed since you are adding an extra storage, I would argue that resizing your volumes should be allowed too when it's available. Opened this feature request.

-- Rico
Source: StackOverflow