Volumes
This document describes the KraftCloud Volumes REST 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 unikernel. 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 a running unikernel |
busy | There are maintenance tasks running on the volume |
error | The volume is in an error state that needs inspection by a KraftCloud engineer |
These are reported as volume state
by the endpoints.
API Endpoints
The KraftCloud Volumes REST 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
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 volume.
Request
Endpoints:
GET /v1/volumes
GET /v1/volumes/<UUID>
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
uuid | name 1 | UUID | Name | ✔️ | UUID or name of the volume to get the status for |
1 Not allowed in local scope.
You need to specify either uuid
or name
.
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 |
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 1 | array of objects | List of instances that this volume is attached to |
uuid | UUID | UUID of the instance |
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 A volume can currently be attached to a single instance only
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
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
.
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 an Instance
Detaches a volume from an instance.
The instance from which to detach must in stopped
state.
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
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
uuid | name 1 | UUID | Name | ✔️ | UUID or name of the volume to detach |
1 Not allowed in local scope.
You need to specify either uuid
or name
.
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>
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
uuid | name 1 | UUID | Name | ✔️ | UUID or name of the volume to delete |
1 Not allowed in local scope.
You need to specify either uuid
or name
.
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
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 |