Volume

A volume can be associated to containers or storage pools.

* A container can have many volumes and containers are mapped to volumes the mount link on a container.
* A storage pool owns many volumes. The volume is only available to containers deployed on hosts that are part of the storage pool. When a volume is being created, you do not directly associate it to a storage pool. You will only need to specify a driver and during allocation, Rancher will resolve it to a storage pool.

Resource Fields

Writeable Fields

Field Type Create Update Default Notes
description string Optional Yes -  
driver string Optional - -  
driverOpts map[string] Optional Yes -  
hostId host Optional Yes - The unique identifier for the associated host
name string Yes - -  
sizeMb int Optional - -  
stackId stack Optional - -  
storageDriverId storageDriver Optional - -  
volumeTemplateId volumeTemplate Optional - -  

Read Only Fields

Field Type Notes
accessMode string  
externalId string  
id int The unique identifier for the volume
imageId image  
instanceId instance The unique identifier for the associated instance
isHostPath boolean  
mounts array[mountEntry]  
uri string  


Please read more about the common resource fields. These fields are read only and applicable to almost every resource. We have segregated them from the list above.

Operations

CreatePOST: /v2-beta/projects/${PROJECT_ID}/volumes

curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
	"description": "string",
	"driver": "string",
	"driverOpts": {
		"key": "value-pairs"
	},
	"hostId": "reference[host]",
	"name": "string",
	"sizeMb": 0,
	"stackId": "reference[stack]",
	"storageDriverId": "reference[storageDriver]",
	"volumeTemplateId": "reference[volumeTemplate]"
}' 'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/volumes'

DeleteDELETE: /v2-beta/projects/${PROJECT_ID}/volumes/${ID}

curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X DELETE \
'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/volumes/${ID}'

UpdatePUT: /v2-beta/projects/${PROJECT_ID}/volumes/${ID}

curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X PUT \
-H 'Content-Type: application/json' \
-d '{
	"description": "string",
	"driverOpts": {
		"key": "value-pairs"
	},
	"hostId": "reference[host]"
}' 'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/volumes/${ID}'

Actions

restorefrombackup POST: /v2-beta/projects/${PROJECT_ID}/volumes/${ID}?action=restorefrombackup


Input: RestoreFromBackupInput

Field Type Required Default Notes
backupId backup Yes    


curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
	"backupId": "reference[backup]"
}' 'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/volumes/${ID}?action=restorefrombackup'


Output: A volume resource

reverttosnapshot POST: /v2-beta/projects/${PROJECT_ID}/volumes/${ID}?action=reverttosnapshot


Input: RevertToSnapshotInput

Field Type Required Default Notes
snapshotId snapshot Yes    


curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
	"snapshotId": "reference[snapshot]"
}' 'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/volumes/${ID}?action=reverttosnapshot'


Output: A volume resource

snapshot POST: /v2-beta/projects/${PROJECT_ID}/volumes/${ID}?action=snapshot


Input: VolumeSnapshotInput

Field Type Required Default Notes
name   No    


curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
	"name": "string"
}' 'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/volumes/${ID}?action=snapshot'


Output: A snapshot resource

Edit this page