简体   繁体   中英

Kubernetes (GKE) persistent volume resizing not working.

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.

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM