Kubernetes – dynamic provisioning of storage

I have a deployment configuration as follows:

apiVersion: extensions/v1beta1
kind: Deployment
--- REMOVED FOR BREVITY ---
      volumes:
      - gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-disk}
        name: devtasker-disk
      - gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-pg}
        name: devtasker-pg

This works fine, however it requires the persistent volumes to be created manually and then the deployment can take place.

  • Docker + WerckerCi: Tag not found
  • Kitchen and Kitchen-docker
  • Unable to push image to Docker Hub registry
  • Prune unused images in OpenShift Origin 1.1.6
  • Multiple docker containers as web server on a single IP
  • what's the best way to let kubenetes pods communicate with each other?
  • I saw in Kubernetes 1.4 they have released “Dyanmic Provisioning & Storage Classes”.

    I have added a storage class as follows:

    kind: StorageClass
    apiVersion: storage.k8s.io/v1beta1
    metadata:
      name: ssd-storage
    provisioner: kubernetes.io/gce-pd
    parameters:
      type: pd-ssd
    

    I now want to add a PVC to my deployment configuration file mentioned above. The standard PVC for the above storage class goes like this:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      annotations: {volume.beta.kubernetes.io/storage-class: ssd-storage}
      name: claim1
    spec:
      accessModes: [ReadWriteOnce]
      resources:
        requests: {storage: 30Gi}
    

    Im struggling to get the above PVC into my deployment configuration mentioned in the first code block above.

    I tried this:

          volumes:
          - gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-disk}
            name: devtasker-disk
          - gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-pg}
            name: devtasker-pg
          - persistentVolumeClaim: {claimName: ssd-storage, annotations: {volume.beta.kubernetes.io/storage-class: ssd-storage}}
            name: ssd-storage
    

    .. but I haven’t had any luck with many different combinations. I get the following:

    error validating "kubernetes/deployment.yml": error validating data: found invalid field annotations for v1.PersistentVolumeClaimVolumeSource; if you choose to ignore these errors, turn validation off with --validate=false
    

    Could anyone please point me in the right direction here?

  • Dockerhub fails to build my Dockerfile
  • Persisting MySQL data in Docker
  • Postgres stream replication master large diff between pg_current_xlog_location and sent_location
  • Docker creating a new image with an added Java application
  • How do I stop my docker VM from attaching a debugger to my executable?
  • .NET Core publish error: “Unable to find msdeploy.exe, please install it and try again”
  • One Solution collect form web for “Kubernetes – dynamic provisioning of storage”

    The storage class tells how to create the PV. The PVC claim requests the actual PV from the underlining infrastructure.

    Your deployment should only know about the PVC, so using your example you would end up with the following and remove the gcePersistentDisk entries:

    volumes:
       - name: storage
         persistentVolumeClaim
           claimName: claim1
       - name: storage2
         persistentVolumeClaim
           claimName: claim2
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.