Skip to Content

Google Professional Cloud Developer: How to Expand Persistent Disk Size in GKE and Make it Visible in Pods?

Learn how to properly expand the size of a persistent disk in Google Kubernetes Engine (GKE) and make the additional space visible in application Pods. Detailed explanation of the correct steps to take based on a sample Google Professional Cloud Developer certification exam question.

Table of Contents

Question

You recently deployed an application to GKE where Pods are writing files to a Compute Engine persistent disk. You have created a PersistentVolumeClaim (PVC) and a PersistentVolume (PV) object on Kubernetes for the disk, and you reference the PVC in the deployment manifest file.

You recently expanded the size of the persistent disk because the application has used up almost all of the disk space. You have logged on to one of the Pods, and you notice that the disk expansion is not visible in the container file system. What should you do?

A. Set the spec.capacity.storage value of the PV object to match the size of the persistent disk. Apply the updated configuration by using kubectl.
B. Recreate the application Pods by running the kubectl delete deployment DEPLOYMENT_NAME && kubectl apply deployment.yaml command, where the DEPLOYMENT_NAME parameter is the name of your deployment and deployment.yaml is its manifest file.
C. Set the spec.resources.requests.storage value of the PVC object to match the size of the persistent disk. Apply the updated configuration by using kubectl.
D. In the Pod, resize the disk partition to the maximum value by using the fdisk or parted utility.

Answer

C. Set the spec.resources.requests.storage value of the PVC object to match the size of the persistent disk. Apply the updated configuration by using kubectl.

Explanation

When expanding the size of a Compute Engine persistent disk used by Pods in Google Kubernetes Engine (GKE), you need to take additional steps beyond just increasing the disk size for the changes to be visible in the Pods’ filesystems.

The correct solution is C: Set the spec.resources.requests.storage value of the PersistentVolumeClaim (PVC) object to match the new size of the persistent disk. Then apply the updated PVC configuration using the kubectl command.

Here’s why:

  • The PersistentVolumeClaim defines the requested storage capacity that the Pods expect to use. If you expand the persistent disk size without updating the PVC, the Pods will still only see the original smaller capacity.
  • Updating the PVC’s spec.resources.requests.storage to match the expanded persistent disk size will signal to Kubernetes that the Pods should now have access to the additional space.
  • Applying the updated PVC configuration with kubectl will make the changes take effect.

The other options are incorrect:

  • A is wrong because you update the PVC, not the PersistentVolume (PV) directly.
  • B is wrong because deleting and recreating the deployment is unnecessary. The existing Pods will see the expanded space once the PVC is updated.
  • D is wrong because you should not manually resize partitions in the Pod. Let Kubernetes handle provisioning the additional space to the Pods based on the PVC.

In summary, to make an expanded Compute Engine persistent disk’s size visible to GKE Pods using it, you must update the spec.resources.requests.storage of the PVC to match the new disk size and apply the changes with kubectl. This will allow the Pods to properly utilize the additional storage capacity.

Google Professional Cloud Developer certification exam assessment practice question and answer (Q&A) dump including multiple choice questions (MCQ) and objective type questions, with detail explanation and reference available free, helpful to pass the Google Professional Cloud Developer exam and earn Google Professional Cloud Developer certification.