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 describe how 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 kubernetes their own parameters.

volume-plans:
  ebs:
    kubernetes:
        storage-class: my-ebs-storage-class

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 configured. These can be created and managed by using the 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 PersistentVolume using the plugin specified in the plan with the opt received in the command line. Also, one PersistentVolumeClaim would be created and bound to the PersistentVolume.

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

Volume binds

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

Example

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

$ tsuru volume create myvol ebs -o capacity=1Gi
resource "tsuru_volume" "myvol" {
  name  = "myvol"
  owner = "myteam"
  plan  = "ebs"
  options = {
    "capacity" = "1Gi"
  }
}

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

$ tsuru volume bind myvol /mnt/mountpoint -a my-app
resource "tsuru_volume_bind" "myvol" {
  app         = "my-app"
  volume      = "myvol"
  mount_point = "/mnt/mountpoint"
}

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:

volume-plans:
  minikube-plan:
    kubernetes:
      storage-class: standard

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

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