Volumes

Volumes allow applications running on tsuru to use external storage volumes mounted on their filesystem.There are three concepts involved in the process: volume plans, volume and volume binds.

Volume Plans

Volume plans are managed by tsuru administrators and are configured in tsuru.conf file. Volume plans describehow each volume that will be associated to this plan will be created by each provisioner.

The following configuration register a volume plan called ebs that is supported by swarm and kubernetes usingdifferent parameters. Each has a own set of parameters that may be set on the configuration file.

  1. volume-plans:
  2. ebs:
  3. swarm:
  4. driver: rexray/ebs
  5. kubernetes:
  6. storage-class: my-ebs-storage-class

On swarm a driver must be specified along with its parameters. On Kubernetes, volume plans may use a volume plugin or a storage class.

Volumes

Volumes are created by tsuru users using one of the plans previously configurated. These can be created and managed by usingthe tsuru client. The behavior is provisioner specific:

On Kubernetes provisioner

Creating a volume with a plan that has no storage-class defined will cause tsuru to manually create one PersistentVolumeusing the plugin specified in the plan with the opt received in the command line. Also, one PersistentVolumeClaim would be created and bound tothe PersistentVolume.

If the plan specifies a storage-class instead of a plugin only the PersistentVolumeClaim will be created using the specified storage-class.

On Swarm provisioner

A new volume would be created (i.e. docker volume create) using the driver informed in the plan and the volume opt would be a merge betweenthe plan opt and command line opt.

Volume binds

Volumes binds, like service binds, associate a given application to a previously created volume. This is the moment whenthe volume will be made available to the application by the provisioner. The bind/unbind actions can be triggered by the tsuruclient.

Example

Supose an ebs volume plan is registered in tsuru configuration, one can create a volume using tsuru client:

  1. $ tsuru volume create myvol ebs -o capacity=1Gi

To be able to use this volume from an app, bind to it:

  1. $ tsuru volume bind myvol /mnt/mountpoint -a my-app

Volumes with Minikube

If you’re running minikube, you can share a hostPath volume among your app units. Add the following configuration to tsuru config file:

  1. volume-plans:
  2. minikube-plan:
  3. kubernetes:
  4. storage-class: standard

Then, to create a volume and bind it to your app:

  1. tsuru volume create my-vol minikube-plan -p my-kubernetes-pool -t my-team -o capacity=1Gi -o access-modes=ReadWriteMany
  2. tsuru volume bind my-vol /mnt/mountpoint -a my-app

原文: https://docs.tsuru.io/1.6/managing/volumes.html