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.

  • Assign domain name to the container
  • can't run fig up it always gets killed
  • How to run etcd cluster in docker using ansible?
  • “update --memory” can not work
  • docker run ubuntu on mac and nothing happens
  • Machine created as normal user isn't visible for administrator
  • 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?

  • How to handle differences in Dockerfile for dev/prod
  • PhpStorm runs only local PHPUnit configuration. How to force it to use remote (Docker)?
  • How to change docker installation directory in centos 7 with docker 1.13 version
  • Docker compose, interpolation of the assigned port
  • Destroy Docker container from Marathon kills Mesos slave
  • Docker save image to tar through remote API
  • 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.