0

I have a statefulset from mongo with 2 volumemounts:

          volumeMounts:
            - name: mongo-persistent-storage
              mountPath: /data/db
            - name: mongo-config-storage
              mountPath: /data/configdb

I want to know how to add the second volume in volumeClaimTemplates:

  volumeClaimTemplates:
  - metadata:
      name: mongo-persistent-storage
      annotations:
          volume.beta.kubernetes.io/storage-class: "sc-infra"
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 2Gi
  • the thing is called volumeClaimTemplates (plural) and it contains an array or objects. So it certainly is possible to specify more than one. – The Fool Jan 19 '22 at 09:47

2 Answers2

3

Just append additional claim to your volumeClaimTemplates. Example:

volumeClaimTemplates:
- metadata:
    name: mongo-persistent-storage
    annotations:
       volume.beta.kubernetes.io/storage-class: "sc-infra"
  spec:
    accessModes: [ "ReadWriteOnce" ]
    resources:
      requests:
        storage: 2Gi
- metadata:              # <-- append another claim
    name: mongo-config-storage
  spec:
    storageClassName: sc-infra
    accessModes: ["ReadWriteOnce"]
    resources:
      requests:
        storage: 1Gi
gohm'c
  • 13,492
  • 1
  • 9
  • 16
0

Yes, you can have more than one PVC in a statefulset.

P Ekambaram
  • 15,499
  • 7
  • 34
  • 59