Configuring Service storage
Given the ephemeral nature of containers, it’s important to consider storage solutions to avoid data loss. We suggest mounting volumes from your container to the host.
Adding simple storage volumes
volumes directive of the
service.yml allows you to mount custom host folders inside your container. This is useful if you need to run a database service for instance, as data written to the local filesystem of your container will not be persisted between container instances.
The volumes option is expressed as a comma separated list with the following form:
You can optionally add
rw to specify that the container can read/write to the host folder (the default is read/write).
Paths must be absolute.
services: <service_name>: volumes: ["/tmp:/tmp_host", "/readonly/folder:/mnted_readony:ro"]
Adding advanced storage volumes
If you need to connect a container to a non-standard volume (for example nfs), Maestro supports all the same volume types as Kubernetes.
Advanced storage volumes are also defined in YAML format, but in a more verbose syntax. Our “simple” example above, using hostPath, would be written as:
services: <service_name>: volumes: - mount_path: "/tmp" host_path: path: "/tmp_host"
Maestro supports all Kubernetes-valid syntax for volume definitions. For example an emptyDir volume would look something like:
services: <service_name>: volumes: - mount_path: "/cache" empty_dir: medium: "Memory"
This would mount an emptyDir volume in the
/cache folder of your container(s) and that volume would use RAM for storage instead of the disk (because
medium is set to “memory”).
Maestro supports the following general settings for all volume-types:
|mount_path||string||Path within the container at which the volume should be mounted. Must not contain
|mount_propagation||string||Determines how mounts are propagated from the host to container and the other way around. When not set,
|read_only||boolean||Mounted read-only if true, read-write otherwise. Defaults to false.|
|sub_path||string||The path within the volume from which the container's volume should be mounted. Defaults to
|sub_path_expr||string||Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to
For more information on any of these settings, please consult the official Kubernetes docs about volumes.