Expanding EBS volume in use as PVC in kubernetes pod

Viewed 124

I am working with a couple of k8s pods that have a PVC attached to it as an EBS volume in AWS. I made the mistake of increasing the space of the volume through the EBS console in AWS. I was thinking I could do it through the EBS console and then exec into the container on the pod and "extend the file system". After getting into the container, I realized I was not able to extend the file system directly in the container.

That is when I came across PVC and how to increase the volume through the k8s resource:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"files","namespace":"default"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"150Gi"}},"storageClassName":"default"}}
    pv.kubernetes.io/bind-completed: "yes"
    pv.kubernetes.io/bound-by-controller: "yes"
    volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/aws-ebs
    volume.kubernetes.io/storage-resizer: kubernetes.io/aws-ebs
  creationTimestamp: "2021-05-20T12:18:55Z"
  finalizers:
  - kubernetes.io/pvc-protection
  name: files
  namespace: default
  resourceVersion: "202729286"
  selfLink: /api/v1/namespaces/default/persistentvolumeclaims/files
  uid: a02bb805-de70-4fc8-bcef-a4943eb4ca0b
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 200Gi
  storageClassName: default
  volumeMode: Filesystem
  volumeName: pvc-a02bb805-de70-4fc8-bcef-a4943eb4ca0b
status:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 150Gi
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2022-06-28T21:15:01Z"
    message: Waiting for user to (re-)start a pod to finish file system resize of
      volume on node.
    status: "True"
    type: FileSystemResizePending
  phase: Bound

I have increased the size in this resource to the same size I manually increased it to in the EBS console. Additionally, I have added the allowVolumeExpansion attribute to the StorageClass and set it to true. However, I am still seeing the old size of the volume after deleting any linked pods to this PVC. Any ideas how I can increase the PVC would be helpful.

0 Answers
Related