我听说在 Kubernetes 的后续版本中(如果我没记错的话是 1.9 及以上版本;我有 1.10),只要allowVolumeExpansion: true
在 StorageClass 配置中设置,就可以扩展 PersistentVolume。
就我而言,在 GCP 上,我的 PVC 使用的 StorageClass 没有那行,而且我也无法添加它。
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.beta.kubernetes.io/is-default-class: "true"
creationTimestamp: 2018-05-30T17:07:33Z
labels:
addonmanager.kubernetes.io/mode: EnsureExists
kubernetes.io/cluster-service: "true"
name: standard
resourceVersion: "8741704"
selfLink: /apis/storage.k8s.io/v1/storageclasses/standard
uid: f1bd0421-642b-11e8-bb11-42010a9a00b5
parameters:
type: pd-standard
provisioner: kubernetes.io/gce-pd
reclaimPolicy: Delete
volumeBindingMode: Immediate
因此,我想将 PV 及其对应的 PVC 从 8Gi 增加到 100Gi。最好的方法是什么?有没有办法在保留数据的同时做到这一点,还是必须先删除当前 PV 才能创建新的 PV?
这是 PV YAML:
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
kubernetes.io/createdby: gce-pd-dynamic-provisioner
pv.kubernetes.io/bound-by-controller: "yes"
pv.kubernetes.io/provisioned-by: kubernetes.io/gce-pd
creationTimestamp: 2018-05-31T10:30:39Z
finalizers:
- kubernetes.io/pv-protection
labels:
failure-domain.beta.kubernetes.io/region: europe-west2
failure-domain.beta.kubernetes.io/zone: europe-west2-c
name: pvc-a70ca000-64bd-11e8-bb11-42010a9a00b5
resourceVersion: "8728415"
selfLink: /api/v1/persistentvolumes/pvc-a70ca000-64bd-11e8-bb11-42010a9a00b5
uid: a9e8c071-64bd-11e8-bb11-42010a9a00b5
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 8Gi
claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: production-postgres
namespace: neserver-6540663
resourceVersion: "85487"
uid: a70ca000-64bd-11e8-bb11-42010a9a00b5
gcePersistentDisk:
fsType: ext4
pdName: gke-cluster-1-320626e3-pvc-a70ca000-64bd-11e8-bb11-42010a9a00b5
persistentVolumeReclaimPolicy: Delete
storageClassName: standard
status:
phase: Bound
答案1
遗憾的是,GKE 尚不支持此功能。您可以使用以下方式提交功能请求,以便在 GKE 的未来版本中启用此功能:公共问题追踪