diff --git a/SUMMARY.md b/SUMMARY.md index d118f442..8a16f82c 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -441,7 +441,8 @@ * [No Space Left on the Device Warning](deployment/deployment-guide/troubleshooting/no-space-left-on-the-device-warning.md) * [Restart Deployment or StatefulSets to Redistribute Pods across Nodes](deployment/deployment-guide/redistribute-pods-across-nodes-by-restarting-deployment-statefulsets.md) * [Rerun Jobs in Kubernetes Cluster](deployment/deployment-guide/rerun-jobs-in-kubernetes-cluster.md) - * [Persistent Storage](deployment/persistent-storage.md) + * [Persistent Storage](deployment/persistent-storage/README.md) + * [Resizing Persistent Volume Claim in Kubernetes Cluster](deployment/persistent-storage/resizing-persistent-volume-claim-in-kubernetes-cluster.md) * [Documentation Guides](documentation-guides/README.md) * [Documentation Guidelines](documentation-guides/documentation-guidelines/README.md) * [Embed a Miro diagram](documentation-guides/documentation-guidelines/embed-a-miro-diagram.md) diff --git a/deployment/persistent-storage.md b/deployment/persistent-storage/README.md similarity index 100% rename from deployment/persistent-storage.md rename to deployment/persistent-storage/README.md diff --git a/deployment/persistent-storage/resizing-persistent-volume-claim-in-kubernetes-cluster.md b/deployment/persistent-storage/resizing-persistent-volume-claim-in-kubernetes-cluster.md new file mode 100644 index 00000000..a25b38ea --- /dev/null +++ b/deployment/persistent-storage/resizing-persistent-volume-claim-in-kubernetes-cluster.md @@ -0,0 +1,94 @@ +--- +description: Guide on Resizing PVC (Persistent Volume Claim) in Kubernetes Cluster +layout: + title: + visible: true + description: + visible: false + tableOfContents: + visible: true + outline: + visible: true + pagination: + visible: true +--- + +# Resizing Persistent Volume Claim in Kubernetes Cluster + +When you require additional storage for your application, you may need to resize a Persistent Volume Claim (PVC) in the Kubernetes cluster. This document provides step-by-step instructions to resize a PVC in a Kubernetes cluster. + +## **Prerequisites** + +* Your PVC's StorageClass has to support volume expansion. Verify that your StorgeClass has `allowVolumeExpansion: true` +* Ensure you have the necessary permissions to edit PVCs and resize volumes. + +## Resizing a PVC + +There may be downtime when resizing a PVC in Kubernetes, especially when transferring data or resizing file systems. To securely resize a PVC, turn off the related service and follow the instructions below. + +1. Identify the PVC you want to resize. Run the below command. + + ```bash + kubectl get pvc -n + ``` +2. Identify the pods that are using this PVC. + + ```bash + kubectl get pods -n --field-selector=spec.volumes.persistentVolumeClaim.claimName= + ``` + + You must end the running application in order to safely resize the PVC. If the PVC is attached to a Deployment, StatefulSet, or another workload, scale it down to zero replicas.\ + **For a Deployment** + + ```bash + kubectl scale deployment --replicas=0 -n + ``` + + **For a StatefulSet** + + ```bash + kubectl scale statefulset --replicas=0 -n + ``` +3. Confirm that the pods have been scaled down. + + ```bash + kubectl get pods -n + ``` +4. Edit the PVC to update the `spec.resources.requests.storage` field with the new size. Run the following command. + + ```bash + kubectl edit pvc -n + ``` +5. Edit the storage field to Increase the storage size. For example, change 10GB to 20GB. + + ```yaml + resources: + requests: + storage: 10Gi + ``` +6. After updating the PVC, check the status to ensure the resize operation succeeds. + + ```shell + kubectl get pvc -n + ``` +7. After resizing the PVC and verifying that everything is in order, scale the deployment or stateful set back to its initial number of replicas.\ + **For a Deployment** + + ``` + kubectl scale deployment --replicas= -n + ``` + + **For a StatefulSet** + + ``` + kubectl scale statefulset --replicas= -n + ``` +8. Verify that the pods are running + + ``` + kubectl get pods -n + ``` + +Note: + +You can use the Rancher UI to resize the PVC by following the procedures listed above.