<p>How to use a storage class for statefulset?  I've created the StorageClass. I also created PVC but i'm a bit confused if PVC needs to be create since PVC already requests storage and volumeClaimTemplates also requests storage. Eitherway its not working with or with out pvc.</p>
<p>I get the following error:</p>
<pre><code>create Pod dbhost001-0 in StatefulSet dbhost001 failed error: failed to create PVC mysql-dev-dbhost001-0: PersistentVolumeClaim &quot;mysql-dev-dbhost001-0&quot; is invalid: spec.resources[storage]: Required value
create Claim mysql-dev-dbhost001-0 for Pod dbhost001-0 in StatefulSet dbhost001 failed error: PersistentVolumeClaim &quot;mysql-dev-dbhost001-0&quot; is invalid: spec.resources[storage]: Required value
</code></pre>
<p><code>storageClass.yml</code>:</p>
<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ebs-sc
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
reclaimPolicy: Retain
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
</code></pre>
<p><code>Statefultset.yml</code>:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
....
....
  volumeClaimTemplates:
  - metadata:
      name: mysql-dev
    spec:
      accessModes:
        - ReadWriteOnce
      storageClassName: ebs-sc
      resources:
        requests:
          stroage: 2Gi
</code></pre>
<p>I'm not sure if pvc is needed? I was using this for a normal replicaset deployment. But not sure if Statefulset needs this.</p>
<p><code>PersistentVolumeClaim.yml</code>:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-dev
  namespace: test-db-dev
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ebs-sc
  resources:
    requests:
      storage: 2Gi
</code></pre>

<p>Figured it out.</p>
<p>First there was a typo in <code>Statefultset.yml</code> it should be <code>storage</code> instead of <code>stroage</code>.</p>
<p>Second there is no need for <code>PersistentVolumeClaim</code> since <code>volumeClaimTemplates</code> is the same thing which claims from storage class.</p>
