Volumes

Volumes let you store persistent data across Deployments

Volumes is still a Beta feature and is currently available only for AWS EKS based users

Volumes are a container level deployment-time configuration that let's you mount Persistent Block Storage onto a path on the containers. Volume and the specific path it attaches to are mentioned while creating a new Deployment.

There are a couple of points to remember when using volume.

  1. A volume can only be attached to one path in one container at a time.

  2. A volume needs to be freed by deleting the deployment before attaching it in another deployment.

How can Volumes be used?

Setup AWS Elastic Block Storage for Dockup by following this nice documentation we have prepared for you.

The deployment form would looks like this with optional volumes:

Deployment form with volume mount option

For this particular deployment, it makes sense to have a volume mounted on a path for the postgres container. This would help us re-use the data from this deployment on future deployments having the same container. Postgres data by default has the path /var/lib/postgresql/data but this might be different for you depending on the container. It is recommended that you check with the documentation of the container image for configurable paths.

Add volume and path

That's all you have to do here. Go ahead, deploy this form and you should now be able to use the deployment with a mounted volume. Once you are done with this deployment, delete it and the Volume should be "Available" in a few seconds for re-use.

Make sure the path for the container starts with "/"and there are no trailing slashes. Both volume and a path is required to create a valid mount on the container.

Reusing volume across deployments

We will now use OmniDB to add some dummy data to the postgrescontainer.

Insert dummy data

We have now added some data on to the database. Now, let's see how the data we wrote on the postgres container persists for re-use on another fresh deployment.

Firstly, we will delete the current deployment and create a new deployment of the blueprint using the same volume and path for the postgres container.

We can then deploy the same blueprint with same volume mount specifications

Another deployment with same volume and path

Let's open up omnidb for the new postgres container and see if we have the data from the previous deployment.

Verify data persistence after re-use

For containers like "postgres", the data directory and initialization depends on the version. So a mismatch in the versions across deployments would cause containers to fail.

Please consider these points when re-using volumes across different types of containers:

  1. Containers like postgres depend on version when using data directory, so a mismatch in version across deployment would cause the container to fail. ie. a volume that had postgres data initialised by a PG 9.5 would fail on PG 11.0 container. One way to prevent this is to use custom data directory for different versions of postgres by specifying the same via PGDATA environment variable.

  2. Since volumes are used to persist data across deployments, Dockup does not clean them after deleting deployments. Although this is intentional, this could cause data inconsistency if the same path is being used by several other deployments.

We recommend the usage of multiple smaller volumes dedicated for each blueprint. In that way, the data that resides in them remains clean for the application you are testing on Dockup. :)

‚Äč