Answers: <p>Did you try by specifying a storageClassName since Kubernetes will be using default storage class when it's not specified?
  See <a href="https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/" rel="nofollow noreferrer">Dynamic Provisioning</a> of the blog post and <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Dynamic</a> from Kubernetes documentation?
  Or try with by removing the default storageclass in the cluster to explicitly use given PV and PVC configuration.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-05T10:19:37.203Z
Answers: 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.
Answers: maze
Answers: CC BY-SA 4.0
Answers: 2020-05-05T21:05:25.790Z
Answers: Good to know that was the issue, please accept the answer if you will.
Answers: cnu
Answers: CC BY-SA 4.0
Answers: 2020-05-07T06:54:06.953Z
Answers: 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".
Answers: maze
Answers: CC BY-SA 4.0
Answers: 2020-05-07T14:42:12.483Z
Answers: Ok, I will edit the answer to add clarity about removing the default SC.
Answers: cnu
Answers: CC BY-SA 4.0
Answers: 2020-05-04T02:38:28.677Z
Answers: 2020-05-07T14:43:04.893Z
Answers: 2020-05-07T14:43:04.893Z
Answers: cnu
Body: <p>I am trying to deploy a statefulSet that will use <em>static</em> volume provisioning (claim existing PVs) based on their label. However, it seems that the persistentvolume-controller is trying to provision storage <em>dynamically</em>, as when I <code>kubectl desribe pvc db-data-db-N</code> the Events log states that: </p>
  
  <pre><code>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
  </code></pre>
  
  <p>I have pre-provisioned PVs with this format (I am using Helm):</p>
  
  <pre><code>kind: PersistentVolume
  apiVersion: v1
  metadata:
    name: db-data-{{ $volIndex }}
    labels:
      restoredFromBackup: "true"
  spec:
    capacity:
      storage: 30Gi
    accessModes:
    - ReadWriteOnce
    awsElasticBlockStore:
      volumeID: {{ $volId }}
      fsType: ext4
  </code></pre>
  
  <p>Here is my PVC template:</p>
  
  <pre><code>  volumeClaimTemplates:
    - metadata:
        name: db-data
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 30Gi
        selector:
          matchLabels:
            restoredFromBackup: "true"
  </code></pre>
  
Tags: <kubernetes><kubernetes-volume><persistent-volumes>
Title: Deploying a statefulSet with static volume provisioning but controller insists to use dynamic
UserDisplayName: maze
ThreadText: # Deploying a statefulSet with static volume provisioning but controller insists to use dynamic
  
  (Asked by: username_0 on 2020-05-03)
  
  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"
  
  ```
  
  **Tags:** kubernetes, kubernetes-volume, persistent-volumes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-05-04. Score: 2 | Accepted answer
  
  Did you try by specifying a storageClassName since Kubernetes will be using default storage class when it's not specified?
  See [Dynamic Provisioning](https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/) of the blog post and [Dynamic](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) from Kubernetes documentation?
  Or try with by removing the default storageclass in the cluster to explicitly use given PV and PVC configuration.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_1**: Good to know that was the issue, please accept the answer if you will.  
  > **username_0**: 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".  
  > **username_1**: Ok, I will edit the answer to add clarity about removing the default SC.  
  
  ---
  
  