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.
-
Enable your storage provisioner to allow volume expansion by setting
allowVolumeExpansion
in the StorageClass totrue
. For example:kubectl patch storageclass/<my-storageclass> --type='json' -p='[{"op": "add", "path": "/allowVolumeExpansion", "value": true }]'
-
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 ...
-
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"}}}}'
-
Scale the Community Kubernetes Operator to
0
.kubectl scale deploy mongodb-kubernetes-operator --replicas=0
-
Remove the StatefulSet without removing the Pods.
kubectl delete sts --cascade=orphan <my-replica-set>
-
Remove the
MongoDBCommunity
resource without removing the Pods.kubectl delete mdbc --cascade=orphan <my-replica-set>
-
Scale the Community Kubernetes Operator to
1
.kubectl scale deploy mongodb-kubernetes-operator --replicas=1
-
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 ...
-
Reapply the
MongoDBCommunity
resource. For example:kubectl apply -f PATH/TO/<MongoDBCommunity-resource>.yaml
-
If your storage provisioner doesn't support online expansion, restart the Pods.
kubectl rollout restart sts <my-replica-set>