Hi Folks,
I have a EKS cluster in AWS, which I manage using eksctl
and kubectl
in EC2. I am tring to create a persistent volume to bind it to multiple pods. I have created an EBS volume (gp2, 5GB) in region us-east-1
for this purpose. My manifests are like below;
storage-class.yml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebsgp2
parameters:
fsType: ext4
type: gp2
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: topology.kubernetes.io/region
values:
- us-east-1
- key: topology.kubernetes.io/zone
values:
- us-east-1a
- us-east-1b
- us-east-1c
pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: aws-pv
labels:
topology.kubernetes.io/region: us-east-1
topology.kubernetes.io/zone: us-east-1a
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 5Gi
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem
csi:
driver: ebs.csi.aws.com
fsType: ext4
volumeHandle: vol-XXXXXXXXXXXXXXXXX
pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ebs-claim
namespace: namespace1
labels:
topology.kubernetes.io/region: us-east-1
topology.kubernetes.io/zone: us-east-1a
spec:
volumeName: aws-pv
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: ebsgp2
I requested the persistent volume claim using the command;
kubectl apply -f pvc.yaml
Then I listed PV and PVC with the commands below;
kubectl get pv
kubectl get pvc -n namespace1
PV got created;
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
aws-pv 5Gi RWO Retain Available 27m
And I could see the status of PV as pending;
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
ebs-claim Pending aws-pv 0 ebsgp2 20s
kubectl get sc
showed below output;
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
ebsgp2 kubernetes.io/aws-ebs Retain WaitForFirstConsumer true 8m53s
gp2 (default) kubernetes.io/aws-ebs Delete WaitForFirstConsumer false 3h23m
To investigate, I described the pvc using command kubectl describe pvc -n namespace1 ebs-claim
and found the output like below;
kubectl describe pvc -n namespace1 ebs-claim
Name: ebs-claim
Namespace: namespace1
StorageClass: ebsgp2
Status: Pending
Volume: aws-pv
Labels: topology.kubernetes.io/region=us-east-1
topology.kubernetes.io/zone=us-east-1a
Annotations: <none>
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 0
Access Modes:
VolumeMode: Filesystem
Used By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning VolumeMismatch 30s (x62 over 15m) persistentvolume-controller Cannot bind to requested volume "aws-pv": storageClassName does not match
Could somebody please tell me why its is happening? Thank you.
Reference;
- aws-ebs-csi-driver/examples/kubernetes/dynamic-provisioning/manifests at master · kubernetes-sigs/aws-ebs-csi-driver · GitHub
- docker - Kubernetes Pod Warning: 1 node(s) had volume node affinity conflict - Stack Overflow
- amazon web services - Kubernetes pod failing with Invalid Volume Zone mismatch - Stack Overflow