title: Snapshotting on google cloud/Kubernetes when using storageClass persistent volumes
body: <p><a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storageclasses" rel="nofollow noreferrer">StorageClasses</a> are the new method of specifying dynamic <code>persistent volume claim</code> (PVC) dependencies within Kubernetes. This avoids the need to explicitly provision one directly with the cloud provider (in my case Google Container Engine (GKE)).</p>
  
  <p>Definition for the <code>StorageClasses</code> (GKE already has a default for <code>standard</code> class)</p>
  
  <pre><code>---
  kind: StorageClass
  apiVersion: storage.k8s.io/v1
  metadata:
    name: fast
  provisioner: kubernetes.io/gce-pd
  parameters:
    type: pd-ssd
    zone: europe-west1-b
  </code></pre>
  
  <p>Definition for the actual PVC</p>
  
  <pre><code>---
  apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: nfs-server-pvc
    namespace: staging
  spec:
    accessModes: [ "ReadWriteOnce" ]
    resources:
      requests:
        storage: 100Gi
    storageClassName: "standard"
  </code></pre>
  
  <p>Here is the result of <code>kubernetes get storageclass</code>:</p>
  
  <pre><code>NAME                 TYPE
  fast                 kubernetes.io/gce-pd
  standard (default)   kubernetes.io/gce-pd
  </code></pre>
  
  <p>Here is the result of <code>kubernetes get pvc</code>:</p>
  
  <pre><code>NAME             STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS   AGE
  nfs-pvc          Bound     nfs                                        1Mi        RWX                          119d
  nfs-server-pvc   Bound     pvc-905a810b-3f13-11e7-82f9-42010a840072   100Gi      RWO           standard       81d
  </code></pre>
  
  <p>I would like to continue taking snapshots of the volumes but the dynamic nature of the <code>volume</code> names created (in this case <code>pvc-905a810b-3f13-11e7-82f9-42010a840072</code>), mean i cannot continue with the following command that i had been using via cron (note the "nfs" name is now incorrect):</p>
  
  <pre><code>gcloud compute --project "XXX-XXX" disks snapshot "nfs" --zone "europe-west1-b" --snapshot-names "nfs-${DATE}"
  </code></pre>
  
  <p>I guess this boils down to Kubernetes allowing explicit naming through StorageClass-based PVC. The <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storageclasses" rel="nofollow noreferrer">docs</a> don't seem to allow this. Any ideas?</p>