|
| 1 | +# Kubernetes Resize User Guide (Alpha) |
| 2 | + |
| 3 | +>**Attention:** Volume Resize is an alpha feature. Make sure you have enabled it in Kubernetes API server using `--feature-gates=ExpandCSIVolumes=true` flag. |
| 4 | +>**Attention:** Volume Resize is only available in the driver version v0.6.0+ |
| 5 | +
|
| 6 | +### Install Driver with alpha resize feature |
| 7 | + |
| 8 | +1. [One-time per project] Create GCP service account for the CSI driver and set required roles |
| 9 | + |
| 10 | +``` |
| 11 | +$ PROJECT=your-project-here # GCP project |
| 12 | +$ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create |
| 13 | +$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key |
| 14 | +$ ./deploy/setup-project.sh |
| 15 | +``` |
| 16 | + |
| 17 | +2. Deploy driver to Kubernetes Cluster |
| 18 | + |
| 19 | +``` |
| 20 | +$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key |
| 21 | +$ GCE_PD_DRIVER_VERSION=alpha # Driver version to deploy |
| 22 | +$ ./deploy/kubernetes/deploy-driver.sh |
| 23 | +``` |
| 24 | + |
| 25 | +### Resize Example |
| 26 | + |
| 27 | +This example provisions a zonal PD in both single-zone and regional clusters. |
| 28 | + |
| 29 | +1. Add resize field to example Zonal Storage Class |
| 30 | +``` |
| 31 | +apiVersion: storage.k8s.io/v1 |
| 32 | +kind: StorageClass |
| 33 | +metadata: |
| 34 | + name: csi-gce-pd |
| 35 | +provisioner: pd.csi.storage.gke.io |
| 36 | +parameters: |
| 37 | + type: pd-standard |
| 38 | +volumeBindingMode: WaitForFirstConsumer |
| 39 | +allowVolumeExpansion: true |
| 40 | +``` |
| 41 | + |
| 42 | +2. Create example Zonal Storage Class with resize enabled |
| 43 | +``` |
| 44 | +$ kubectl apply -f ./examples/kubernetes/demo-zonal-sc.yaml |
| 45 | +``` |
| 46 | + |
| 47 | +3. Create example PVC and Pod |
| 48 | +``` |
| 49 | +$ kubectl apply -f ./examples/kubernetes/demo-pod.yaml |
| 50 | +``` |
| 51 | + |
| 52 | +4. Verify PV is created and bound to PVC |
| 53 | +``` |
| 54 | +$ kubectl get pvc |
| 55 | +NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE |
| 56 | +podpvc Bound pvc-e36abf50-84f3-11e8-8538-42010a800002 10Gi RWO csi-gce-pd 9s |
| 57 | +``` |
| 58 | + |
| 59 | +5. Verify pod is created and in `RUNNING` state (it may take a few minutes to get to running state) |
| 60 | +``` |
| 61 | +$ kubectl get pods |
| 62 | +NAME READY STATUS RESTARTS AGE |
| 63 | +web-server 1/1 Running 0 1m |
| 64 | +``` |
| 65 | + |
| 66 | +8. Check current filesystem size on the running pod |
| 67 | +``` |
| 68 | +$ kubectl exec web-server -- df -h /var/lib/www/html |
| 69 | +Filesystem Size Used Avail Use% Mounted on |
| 70 | +/dev/sdb 5.9G 24M 5.9G 1% /var/lib/www/html |
| 71 | +``` |
| 72 | + |
| 73 | +6. Resize volume by modifying the field `spec -> resources -> requests -> storage` |
| 74 | +``` |
| 75 | +$ kubectl edit pvc podpvc |
| 76 | +apiVersion: v1 |
| 77 | +kind: PersistentVolumeClaim |
| 78 | +... |
| 79 | +spec: |
| 80 | + resources: |
| 81 | + requests: |
| 82 | + storage: 9Gi |
| 83 | + ... |
| 84 | +... |
| 85 | +``` |
| 86 | + |
| 87 | +7. Verify actual disk resized on cloud |
| 88 | +``` |
| 89 | +$ gcloud compute disks describe ${disk_name} --zone=${zone} |
| 90 | +description: Disk created by GCE-PD CSI Driver |
| 91 | +name: pvc-10ea155f-e5a4-4a82-a171-21481742c80c |
| 92 | +... |
| 93 | +sizeGb: '9' |
| 94 | +``` |
| 95 | + |
| 96 | +8. Verify filesystem resized on the running pod |
| 97 | +``` |
| 98 | +$ kubectl exec web-server -- df -h /var/lib/www/html |
| 99 | +Filesystem Size Used Avail Use% Mounted on |
| 100 | +/dev/sdb 8.8G 27M 8.8G 1% /var/lib/www/html |
| 101 | +``` |
0 commit comments