Home > Net >  How to Deploy an existing EBS volume to EKS PVC?
How to Deploy an existing EBS volume to EKS PVC?

Time:10-26

I have an existing ebs volume in AWS with data on it. I need to create a PVC in order to use it in my pods. Following this guide: https://medium.com/pablo-perez/launching-a-pod-with-an-existing-ebs-volume-mounted-in-k8s-7b5506fa7fa3

persistentvolume.yaml

kind: PersistentVolume
apiVersion: v1
metadata:
  name: jenkins-volume
  labels:
    type: amazonEBS
spec:
  capacity:
    storage: 60Gi
  accessModes:
    - ReadWriteOnce
  awsElasticBlockStore:
    volumeID: vol-011111111x
    fsType: ext4
[$$]>kubectl describe pv
Name:            jenkins-volume
Labels:          type=amazonEBS
Annotations:     <none>
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:
Status:          Available
Claim:
Reclaim Policy:  Retain
Access Modes:    RWO
VolumeMode:      Filesystem
Capacity:        60Gi
Node Affinity:   <none>
Message:
Source:
    Type:       AWSElasticBlockStore (a Persistent Disk resource in AWS)
    VolumeID:   vol-011111111x
    FSType:     ext4
    Partition:  0
    ReadOnly:   false
Events:         <none>

persistentVolumeClaim.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jenkins-pvc-shared4
  namespace: jenkins
spec:
  storageClassName: gp2
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 60Gi
[$$]>kubectl describe pvc jenkins-pvc-shared4 -n jenkins
Name:          jenkins-pvc-shared4
Namespace:     jenkins
StorageClass:  gp2
Status:        Pending
Volume:
Labels:        <none>
Annotations:   <none>
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode:    Filesystem
Mounted By:    <none>
Events:
  Type    Reason                Age                From                         Message
  ----    ------                ----               ----                         -------
  Normal  WaitForFirstConsumer  12s (x2 over 21s)  persistentvolume-controller  waiting for first consumer to be created before binding
[$$]>kubectl get pvc jenkins-pvc-shared4 -n jenkins
NAME                  STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
jenkins-pvc-shared4   Pending                                      gp2            36s

Status is pending (waiting to the consumer to be attached) - but it should already be provisioned.

CodePudding user response:

try fsType "xfs" instead of ext4

CodePudding user response:

The "waiting for consumer" message suggests that your StorageClass has its volumeBindingMode set to waitForFirstConsumer.

The default value for this setting is Immediate: as soon as you register a PVC, your volume provisioner would provision a new volume.

The waitForFirstConsumer on the other hand would wait for a Pod to request usage for said PVC, before the provisioning a volume.

The messages and behavior you're seeing here sound normal. You may create a Deployment mounting that volume, to confirm provisioning works as expected.

  • Related