3

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.

Dave Michaels
  • 847
  • 1
  • 19
  • 51
  • Link has reason https://kubernetes.io/docs/concepts/storage/persistent-volumes/ Warning: Directly editing the size of a PersistentVolume can prevent an automatic resize of that volume. If you edit the capacity of a PersistentVolume, and then edit the .spec of a matching PersistentVolumeClaim to make the size of the PersistentVolumeClaim match the PersistentVolume, then no storage resize happens. The Kubernetes control plane will see that the desired state of both resources matches, conclude that the backing volume size has been manually increased and that no resize is necessary. – Nataraj Medayhal Jun 29 '22 at 01:56

0 Answers0