Kubernetes in the Wild - Invalid Option "reclaimPolicy"
In this episode of Kubernetes in the Wild, we observe an issue with one of our pods, which is failing to start in EKS. The pod deployment YAML looks like the below containing a persistent volume claim.
|
|
Checking the persistent volume claim with the following command reveals the problem.
kubectl describe pvc mongodb-data
Output:
Name: mongodb-data
Namespace: default
StorageClass: gp2-retain
Status: Pending
Volume:
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{“apiVersion”:“v1”,“kind”:“PersistentVolumeClaim”,“metadata”:{“annotations”:{},“name”:“mongodb-data”,“namespace”:“default”},“spec”:{“acces…
volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/aws-ebs
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Block
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning ProvisioningFailed 6s (x10 over 8m6s) persistentvolume-controller Failed to provision volume with StorageClass “gp2-retain”: invalid option “reclaimPolicy” for volume plugin kubernetes.io/aws-ebs
Mounted By: <none>
Reviewing the storage class gp2-retain YAML definition as noted in the error output reveals the source of the problem, the reclaimPolicy statement is indented within parameters which it shouldn’t be.
To resolve the problem, correct the storage class with reclaimPolicy correctly defined.
After resolving this issue, the pod was still failing to start; this was due to the volumeMode being set to Block instead of Filesystem. The correct YAML is noted below for reference.