2

我想扩展我的持久卷,以便在运行 v1.12.5 的 GKE 集群上进行部署。我更改了存储类以启用卷扩展:

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

之后我更改了 PVC 的大小:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: webcontent
  namespace: k8s-test
  annotations:
    volume.alpha.kubernetes.io/storage-class: default
spec:
  accessModes: [ReadWriteOnce]
  resources:
    requests:
      storage: 2Gi  ---> Old size was 1Gi

删除 pod 后,我像这样检查了 pvc 的状态。然后在几秒钟内,部署中的副本设置重新启动了 pod:

kubectl get pvc -n k8s-test -o yaml
apiVersion: v1
items:
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"volume.alpha.kubernetes.io/storage-class":"default"},"name":"webcontent","namespace":"k8s-test"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"2Gi"}}}}
      pv.kubernetes.io/bind-completed: "yes"
      pv.kubernetes.io/bound-by-controller: "yes"
      volume.alpha.kubernetes.io/storage-class: default
      volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/gce-pd
    creationTimestamp: "2019-03-26T13:32:22Z"
    finalizers:
    - kubernetes.io/pvc-protection
    name: webcontent
    namespace: k8s-test
    resourceVersion: "12957822"
    selfLink: /api/v1/namespaces/k8s-test/persistentvolumeclaims/webcontent
    uid: 95dcdcba-4fcb-11e9-97fd-42010aa400b9
  spec:
    accessModes:
    - ReadWriteOnce
    dataSource: null
    resources:
      requests:
        storage: 2Gi
    storageClassName: standard
    volumeName: pvc-95dcdcba-4fcb-11e9-97fd-42010aa400b9
  status:
    accessModes:
    - ReadWriteOnce
    capacity:
      storage: 1Gi
    conditions:
    - lastProbeTime: null
      lastTransitionTime: "2019-03-26T15:35:28Z"
      message: Waiting for user to (re-)start a pod to finish file system resize of
        volume on node.
      status: "True"
      type: FileSystemResizePending
    phase: Bound
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

所以它似乎只等待文件系统调整大小。如前所述,我多次删除了 pod,并将副本值设置为 0 以终止 pod,但文件系统大小调整没有启动。

我究竟做错了什么?

4

1 回答 1

0

您提到您在删除 pod后检查了状态。根据 Kubernetes文档,状态必须首先是 FileSystemResizePending,然后可以通过删除或缩小部署然后向上来重新启动 pod。

于 2019-03-29T01:41:01.883 回答