1

I am trying to deploy a statefulSet that will use static volume provisioning (claim existing PVs) based on their label. However, it seems that the persistentvolume-controller is trying to provision storage dynamically, as when I kubectl desribe pvc db-data-db-N the Events log states that:

Events:
  Type       Reason              Age               From                         Message
  ----       ------              ----              ----                         -------
  Warning    ProvisioningFailed  9s (x3 over 21s)  persistentvolume-controller  Failed to provision volume with StorageClass "db-data-storage": claim.Spec.Selector is not supported for dynamic provisioning on AWS

I have pre-provisioned PVs with this format (I am using Helm):

kind: PersistentVolume
apiVersion: v1
metadata:
  name: db-data-{{ $volIndex }}
  labels:
    restoredFromBackup: "true"
spec:
  capacity:
    storage: 30Gi
  accessModes:
  - ReadWriteOnce
  awsElasticBlockStore:
    volumeID: {{ $volId }}
    fsType: ext4

Here is my PVC template:

  volumeClaimTemplates:
  - metadata:
      name: db-data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 30Gi
      selector:
        matchLabels:
          restoredFromBackup: "true"
2

Did you try by specifying a storageClassName since Kubernetes will be using default storage class when it's not specified? See Dynamic Provisioning of the blog post and Dynamic from Kubernetes documentation? Or try with by removing the default storageclass in the cluster to explicitly use given PV and PVC configuration.

4
  • Thank you, this was the case - the Cluster had a default StorageClass which was getting used and forcing the PVC to be dynamic. Once I configured there to be no default storageClass then the issue was resolved. – maze88 May 5 '20 at 10:19
  • Good to know that was the issue, please accept the answer if you will. – cnu May 5 '20 at 21:05
  • I didn't mark it (yet) because the first part is misleading, implying that a StorageClass is required. "Did you try by specifying a storageClassName". – maze88 May 7 '20 at 6:54
  • Ok, I will edit the answer to add clarity about removing the default SC. – cnu May 7 '20 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.