Kubernetes (GKE) persistent volume resizing not working.

10/20/2018

I am trying to resize the persistent volume in Google Kubernetes Engine. but I ending up with an error

The PersistentVolumeClaim "pvc1" is invalid: spec: Forbidden: field is immutable after creation

I have been following https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/ guide.

Steps 1. Created a standard.yaml file with following content

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: standard
parameters:
  type: pd-standard
provisioner: kubernetes.io/gce-pd
allowVolumeExpansion: true
reclaimPolicy: Delete

2. Created gke-pvc.yml with following content

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc1
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: standard
  resources:
    requests:
      storage: 20Gi

3. Ran kubectl apply -f standard.yaml

  1. Ran kubectl apply -f gke-pvc.yml

  2. Now ran kubectl edit pvc pvc1 and changed storage from 20Gi to 30 Gi and saved the file but I got error

error: persistentvolumeclaims "pvc1" is invalid error: persistentvolumeclaims "pvc1" is invalid A copy of your changes has been stored to "/tmp/kubectl-edit-0hztl.yaml"

Please help me to solve this issue.

-- Rahul Sharma
docker
google-cloud-platform
google-kubernetes-engine
kubernetes

2 Answers

10/21/2018

This is expected behavior on GKE. I believe feature is available on Kubernetes 1.11 but not yet released on GKE. If you want early access to feature, you may sign up here.

-- dany L
Source: StackOverflow

2/17/2019

It is working currently, after you edit pvc, you get this message:

conditions:
  - lastProbeTime: null
    lastTransitionTime: "2019-02-17T23:31:42Z"
    status: "True"
    type: Resizing

and soon after, this:

    message: Waiting for user to (re-)start a pod to finish file system resize of
      volume on node.
    status: "True"
    type: FileSystemResizePending

Then just delete pod and your volume will be resized

-- lumaks
Source: StackOverflow