<p>I have a PetSet with </p>

<pre><code>  volumeClaimTemplates:
  - metadata:
      name: content
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 2Gi
  - metadata:
      name: database
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 2Gi
  - metadata:
      name: file
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 2Gi
  - metadata:
      name: repository
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 2Gi
</code></pre>

<p>If I annotate it with dynamic volume provisioning it will create volume claims and volumes in random availability zone and pets won't be able to start because in this example each pet requires exactly four volumes 2Gi in size to actually be scheduled.
If I create volumes manually I can have them labeled with <em>failure-domain.beta.kubernetes.io/zone: us-east-1d</em> for example and this way I can create PVCs with the selector that matchLabels by failure-domain. But how do I do something similar with volumeClaimTemplates? I mean I don't want to stick them all to one failure domain sure. But for some reason volume claim template won't create all the volumes for one pet in the same failure domain.</p>

<p>Ideas?</p>

<p>You can create a storage class and add the failure zone there. For example, create a storage class like this:</p>

<pre><code>kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
  name: gp2storage
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  zone: us-east-1b
  encrypted: "true"
</code></pre>

<p>In the example above, we're creating PV's in the zone <code>us-east-1b</code> on AWS. Then in your template reference that storage class:</p>

<pre><code>volumeClaimTemplates:
  - metadata:
      name: data
      annotations:
        volume.beta.kubernetes.io/storage-class: default
</code></pre>
