Volumes
This document describes the Unikraft Cloud Volumes API (v1) for managing persistent volumes.
InitRds vs. Volumes
Initrd (initial ramdisk) and actual volumes serve different purposes. An initrd is a file system loaded into memory during the boot process of the instance. Any new files created as well as any modifications made to files in the initrd are lost when the instance is stopped. In contrast, a volume is a persistent storage device that keeps data across restarts. In addition, it can be initialized with a set of files with one instance and then be detached and attached to a another one.
Volume States
A volume can be in one of the following states:
State | Description |
---|---|
uninitialized | The volume is scheduled to be created |
initializing | The volume is currently created and formatted |
available | The volume is healthy and available to be attached to an instance |
idle | The volume is healthy and attached to an instance. It is possible to detach it in this state |
mounted | The volume is currently mounted in an instance |
busy | There are maintenance tasks running on the volume |
error | The volume is in an error state that needs inspection by a Unikraft Cloud engineer |
These are reported as volume state
by the endpoints.
API Endpoints
The Unikraft Cloud Volumes API provides the following endpoints:
Method | Endpoint | Purpose and Description |
---|---|---|
POST | /v1/volumes | Creates one or more volumes |
GET | /v1/volumes | Returns the current state and configuration of volumes |
DELETE | /v1/volumes | Deletes the specified volumes |
PUT | /v1/volumes/attach | Attaches the volumes to instances |
PUT | /v1/volumes/detach | Detaches volumes from instances |
GET | /v1/volumes/list | Lists all existing volumes |
In the following, the API endpoints are specified relative to this base URL:
With X
being the IATA metro code.
We use fra0
as an example in the documentation.
See the introduciton for more information on how to connect to the API.
Creating Volumes
Creates one or more volumes with the given configuration.
The volumes are automatically initialized with an empty file system.
After initialization the volumes are in the available
state and can be attached to an instance with the PUT /v1/volumes/attach
endpoint.
Note that, the size of a volume cannot be changed after creation.
Request
Endpoints:
POST /v1/volumes
Body Parameter | Type | Default | Required | Description |
---|---|---|---|---|
name 1 | Name | random | Name of the volume | |
size_mb | int | ✔️ | Size of the volume in megabytes |
1If no name is specified a random name of the form vol-X
is auto-generated, where X
is a 5 character long random alphanumeric suffix.
Response
The response is embedded in a JSON object as described in API Responses.
Field | Type | Description |
---|---|---|
status | string | success on success, or error if the request failed |
uuid | UUID | UUID of the newly created volume |
name | Name | Name of the newly created volume |
Getting the Status of a Volume
Returns the current status and the configuration of a particular volume if a UUID or name is specified. Otherwise, returns the current status and configuration of all volumes.
Request
Endpoints:
GET /v1/volumes
GET /v1/volumes/<UUID>
Query Parameter | Type | Default | Required | Description |
---|---|---|---|---|
details | bool | true | Whether to provide detailed status and configuration information | |
name 1 | string | list of strings | Names of volumes to return as comma-separated list | ||
uuid 1 | string | list of strings | UUIDs of volumes to return as comma-separated list |
Body Parameter | Type | Default | Required | Description |
---|---|---|---|---|
uuid | name 1,2 | UUID | Name | ✔️ | UUID or name of the volume to get the status for |
1 Not allowed in local scope.
2 You need to specify either uuid
or name
within the same body object.
Response
The response is embedded in a JSON object as described in API Responses.
Field | Type | Description |
---|---|---|
status 1 | string | success on success, or error if the request failed |
state | State | Current state of the volume |
uuid | UUID | UUID of the volume |
name | Name | Name of the volume |
size_mb | int | Size of the volume in megabytes |
attached_to | array of objects | List of instances that this volume is attached to |
uuid | UUID | UUID of the instance |
name | Name | Name of the instance |
mounted_by | array of objects | List of instances that have this volume mounted |
uuid | UUID | UUID of the instance |
name | Name | Name of the instance |
readonly | bool | Whether the volume is mounted read-only or read-write |
persistent | bool | Indicates if the volume will stay alive when the last instance is deleted that this volume is attached to |
created_at | string | Date and time of creation in ISO8601 |
1 Not when listing all existing volumes.
Attaching a Volume to an Instance
Attaches a volume to an instance so that the volume is mounted when the instance starts.
The volume needs to be in available
state and the instance must in stopped
state.
Currently, each instance can have only one volume attached at most.
Request
Endpoints:
PUT /v1/volumes/attach
PUT /v1/volumes/<UUID>/attach
Body Parameter | Type | Default | Required | Description |
---|---|---|---|---|
uuid | name 1 | UUID | Name | ✔️ | UUID or name of the volume to attach | |
attach_to | object | ✔️ | ||
uuid | name | UUID | Name | ✔️ | UUID or name of the instance to attach the volume to | |
at 2 | string | ✔️ | Path of the mountpoint | |
readonly | bool | false | Whether the volume should be mounted read-only |
1 Not allowed in local scope.
You need to specify either uuid
or name
within the same body object.
2 The path must be absolute, not contain .
and ..
components, and not contain colons (:
).
The path must point to an empty directory.
If the directory does not exist, it is created.
Response
The response is embedded in a JSON object as described in API Responses.
Field | Type | Description |
---|---|---|
status | string | success on success, or error if the request failed |
uuid | UUID | UUID of the volume |
name | Name | Name of the volume |
Detaching a Volume from Instances
Detaches a volume from instances. If no particular instance is specified the volume is detached from all instances. The instances from which to detach must not have the volume mounted. The API returns an error for each instance from which it was unable to detach the volume. If the volume has been created together with an instance, detaching the volume will make it persistent (i.e., it survives the deletion of the instance).
Request
Endpoints:
PUT /v1/volumes/detach
PUT /v1/volumes/<UUID>/detach
Query Parameter | Type | Default | Required | Description |
---|---|---|---|---|
name 1,3 | string | list of strings | Names of volumes to detach as comma-separated list | ||
uuid 1,3 | string | list of strings | UUIDs of volumes to detach as comma-separated list |
Body Parameter | Type | Default | Required | Description |
---|---|---|---|---|
uuid | name 1,2 | UUID | Name | ✔️ | UUID or name of the volume to detach | |
from 3 | object | |||
uuid | name | UUID | Name | ✔️ | UUID or name of the instance to detach the volume from |
1 Not allowed in local scope.
2 You need to specify either uuid
or name
within the same body object.
3 If the from
field is not specified the volume is detached from all instances.
The same applies if the volume is specified via a query parameter.
Response
The response is embedded in a JSON object as described in API Responses.
Field | Type | Description |
---|---|---|
status | string | success on success, or error if the request failed |
uuid | UUID | UUID of the volume |
name | Name | Name of the volume |
Deleting a Volume
Deletes the specified volume. Fails if the volume is still attached to an instance. After this call the IDs associated with the volume are no longer valid.
Request
Endpoints:
DELETE /v1/volumes
DELETE /v1/volumes/<UUID>
Query Parameter | Type | Default | Required | Description |
---|---|---|---|---|
name 1 | string | list of strings | Names of volumes to delete as comma-separated list | ||
uuid 1 | string | list of strings | UUIDs of volumes to delete as comma-separated list |
Body Parameter | Type | Default | Required | Description |
---|---|---|---|---|
uuid | name 1,2 | UUID | Name | ✔️ | UUID or name of the volume to delete |
1 Not allowed in local scope.
2 You need to specify either uuid
or name
within the same body object.
Response
The response is embedded in a JSON object as described in API Responses.
Field | Type | Description |
---|---|---|
status | string | success on success, or error if the request failed |
uuid | UUID | UUID of the volume |
name | Name | Name of the volume |
List Existing Volumes
Lists all existing volumes. You can filter by persistence and volume state. The returned volumes fulfill all provided filter criteria. No particular value is assumed if a filter is not part of the request.
Request
Endpoints:
GET /v1/volumes/list
Body Parameter | Type | Default | Required | Description |
---|---|---|---|---|
persistent | bool | Desired persistence value for filtering | ||
state | State | State for filtering |
Response
The response is embedded in a JSON object as described in API Responses.
Field | Type | Description |
---|---|---|
uuid | UUID | UUID of the volume |
name | Name | Name of the volume |