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.

  • What is the overhead of creating docker images?
  • Docker swarm mode running Hazelcast cluster
  • Post a Json file to elasticsearch running on Docker, Kitematic on Windows 10
  • Docker Compose Expose Spark Worker UI Ports Dynamically to Host When Scaling
  • How to configure nginx to serve static from django running in a docker container
  • Docker Cache BUNDLE INSTALL not working
  • 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?

  • Docker Error : Cannot use --lxc-conf with execdriver: native-0.2
  • Node not found in alpine docker
  • Moving from Vagrant to Vagrant with Docker
  • docker-compose build doesn't re-create some slices of my container, resulting in partially obsolete code
  • Run postgresql docker image with persistent data returns permission error
  • Good strategy for using docker with mongo and data [closed]
  • 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.