Skip to content

Latest commit

 

History

History
101 lines (80 loc) · 3.07 KB

resize-pvc.md

File metadata and controls

101 lines (80 loc) · 3.07 KB

Resize PVC Resources

Resizing the Persistent Volume Claim (PVC) resources for your Community Kubernetes Operator replica sets using the StatefulSet is not yet possible. Instead, follow these steps to resize the PVC resource for each replica set and recreate the StatefulSet.

  1. Enable your storage provisioner to allow volume expansion by setting allowVolumeExpansion in the StorageClass to true. For example:

    kubectl patch storageclass/<my-storageclass> --type='json' -p='[{"op": "add", "path": "/allowVolumeExpansion", "value": true }]'
    
  2. If you don't already have a MongoDBCommunity resource with custom storage specified, create one. For example:

    ---
    apiVersion: mongodbcommunity.mongodb.com/v1
    kind: MongoDBCommunity
    metadata:
      name: example-mongodb
    spec:
      members: 3
      type: ReplicaSet
      version: "6.0.5"
      statefulSet:
        spec:
          volumeClaimTemplates:
            - metadata:
                name: data-volume
              spec:
                resources:
                  requests:
                    storage: 50Gi
    ...
  3. Patch the PVC resource for each replica set.

    kubectl patch pvc/"data-volume-<my-replica-set>-0" -p='{"spec": {"resources": {"requests": {"storage": "100Gi"}}}}'
    kubectl patch pvc/"data-volume-<my-replica-set>-1" -p='{"spec": {"resources": {"requests": {"storage": "100Gi"}}}}'
    kubectl patch pvc/"data-volume-<my-replica-set>-2" -p='{"spec": {"resources": {"requests": {"storage": "100Gi"}}}}'
    
  4. Scale the Community Kubernetes Operator to 0.

    kubectl scale deploy mongodb-kubernetes-operator --replicas=0
    
  5. Remove the StatefulSet without removing the Pods.

    kubectl delete sts --cascade=orphan <my-replica-set>
    
  6. Remove the MongoDBCommunity resource without removing the Pods.

    kubectl delete mdbc --cascade=orphan <my-replica-set>
    
  7. Scale the Community Kubernetes Operator to 1.

    kubectl scale deploy mongodb-kubernetes-operator --replicas=1
    
  8. Add your new storage specifications to the MongoDBCommunity resource. For example:

    ---
    apiVersion: mongodbcommunity.mongodb.com/v1
    kind: MongoDBCommunity
    metadata:
      name: example-mongodb
    spec:
      members: 3
      type: ReplicaSet
      version: "6.0.5"
      statefulSet:
        spec:
          volumeClaimTemplates:
            - metadata:
                name: data-volume
              spec:
                resources:
                  requests:
                    storage: 100Gi
    ...
  9. Reapply the MongoDBCommunity resource. For example:

    kubectl apply -f PATH/TO/<MongoDBCommunity-resource>.yaml
    
  10. If your storage provisioner doesn't support online expansion, restart the Pods.

    kubectl rollout restart sts <my-replica-set>