Creating a PersistentVolume
Function
This API is used to create a PersistentVolume associated with cloud storage (for example, EVS, SFS, and OBS). This API has been discarded. Use the API described in Creating a PersistentVolume.
The format of the storage management URL is https://{clusterid}.Endpoint/uri. In the URL, {clusterid} indicates a cluster ID, and uri indicates the resource path, that is, the path for API access. If https://Endpoint/uri is used, the X-Cluster-ID parameter must be specified in the request header.
URI
POST /api/v1/cloudpersistentvolumes
Request
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| Content-Type | Yes | String | Message body type (format). Possible values:
|
| X-Auth-Token | Yes | String | Requests for calling an API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token. For details on how to obtain a user token, see Authentication. Maximum length: 16,384 characters |
| X-Cluster-ID | No | String | Cluster ID. This parameter is mandatory when the URL format https://Endpoint/uri is used. For details about how to obtain the value, see How to Obtain Parameters in the API URI. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| apiVersion | Yes | String | API version. The value is fixed to v1. Default value: v1 |
| kind | Yes | String | API type. The value is fixed to PersistentVolume. Default value: PersistentVolume |
| metadata | Yes | PersistentVolumeMetadata object | PersistentVolume metadata information. |
| spec | Yes | PersistentVolumeSpec object | PersistentVolume specifications. |
| status | No | PersistentVolumeStatus object | PersistentVolume status information. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | PV name. Enter 1 to 253 characters starting and ending with a letter or digit. Only lowercase letters, digits, hyphens (-), and periods (.) are allowed. PV names must be unique in a namespace. |
| labels | No | Map<String,String> | PV labels, in the format of key-value pairs.
Example label: "foo": "bar" |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| flexVolume | Yes | FlexVolume object | FlexVolume storage plug-in of Kubernetes. |
| persistentVolumeReclaimPolicy | No | String | PV reclaim policy. Possible values:
|
| accessModes | Yes | Array of strings | Access mode of the PersistentVolume.
|
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| driver | Yes | String | Name of the FlexVolume storage plug-in. Set this parameter based on the storage volume type.
|
| fsType | Yes | String | File system type. Set this parameter based on the storage volume type.
|
| options | Yes | Options object | FlexVolume configuration items. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| fsType | Yes | String | File system type. Set this parameter based on the storage volume type.
|
| region | Yes | String | Region where the cloud storage is located. |
| volumeID | Yes | String | UUID of the cloud storage. If the cloud storage is an OBS bucket, set this parameter to the bucket name. |
| storageType | Yes | String | Cloud storage volume type.
|
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| accessModes | No | Array of strings | Access mode of the PersistentVolume. |
| phase | No | String | PV status. Possible values:
|
Response
Status code: 201
| Parameter | Type | Description |
|---|---|---|
| apiVersion | String | API version. The value is fixed to v1. Default value: v1 |
| kind | String | API type. The value is fixed to PersistentVolume. Default value: PersistentVolume |
| metadata | PersistentVolumeMetadata object | PersistentVolume metadata information. |
| spec | PersistentVolumeSpec object | PersistentVolume specifications. |
| status | PersistentVolumeStatus object | PersistentVolume status information. |
| Parameter | Type | Description |
|---|---|---|
| name | String | PV name. Enter 1 to 253 characters starting and ending with a letter or digit. Only lowercase letters, digits, hyphens (-), and periods (.) are allowed. PV names must be unique in a namespace. |
| labels | Map<String,String> | PV labels, in the format of key-value pairs.
Example label: "foo": "bar" |
| Parameter | Type | Description |
|---|---|---|
| flexVolume | FlexVolume object | FlexVolume storage plug-in of Kubernetes. |
| persistentVolumeReclaimPolicy | String | PV reclaim policy. Possible values:
|
| accessModes | Array of strings | Access mode of the PersistentVolume.
|
| Parameter | Type | Description |
|---|---|---|
| driver | String | Name of the FlexVolume storage plug-in. Set this parameter based on the storage volume type.
|
| fsType | String | File system type. Set this parameter based on the storage volume type.
|
| options | Options object | FlexVolume configuration items. |
| Parameter | Type | Description |
|---|---|---|
| fsType | String | File system type. Set this parameter based on the storage volume type.
|
| region | String | Region where the cloud storage is located. |
| volumeID | String | UUID of the cloud storage. If the cloud storage is an OBS bucket, set this parameter to the bucket name. |
| storageType | String | Cloud storage volume type.
|
| Parameter | Type | Description |
|---|---|---|
| accessModes | Array of strings | Access mode of the PersistentVolume. |
| phase | String | PV status. Possible values:
|
Request Example
- Specifying an EVS volume ID and creating a PersistentVolume:
{ "apiVersion" : "v1", "kind" : "PersistentVolume", "metadata" : { "labels" : { "name" : "pv-test" }, "name" : "pv-test" }, "spec" : { "accessModes" : [ "ReadWriteMany" ], "flexVolume" : { "driver" : "huawei.com/fuxivol", "fsType" : "ext4", "options" : { "fsType" : "ext4", "kubernetes.io/namespace" : "default", "region" : "southchina", "volumeID" : "76e01b29-08b9-11e8-9ca5-1051722006ec", "storageType" : "bs" } }, "persistentVolumeReclaimPolicy" : "Delete" } } -
{ "apiVersion" : "v1", "kind" : "PersistentVolume", "metadata" : { "labels" : { "name" : "pv-test" }, "name" : "pv-test" }, "spec" : { "accessModes" : [ "ReadWriteMany" ], "flexVolume" : { "driver" : "huawei.com/fuxivol", "fsType" : "ext4", "options" : { "fsType" : "ext4", "region" : "southchina", "volumeID" : "76e01b29-08b9-11e8-9ca5-1051722006ec", "storageType" : "bs" } }, "persistentVolumeReclaimPolicy" : "Delete" } }
Example Response
Status code: 201
The job for creating a PersistentVolume is successfully delivered.
{
"kind" : "PersistentVolume",
"apiVersion" : "v1",
"metadata" : {
"name" : "pv-test",
"namespace" : "default",
"selfLink" : "/api/v1/namespaces/default/persistentvolumes/pv-test",
"uid" : "e174188f-ff21-11e7-855b-fa163eaf5675",
"resourceVersion" : "174229",
"creationTimestamp" : "2018-01-22T03:11:03Z",
"labels" : {
"name" : "pv-test"
},
"enable" : true
},
"spec" : {
"capacity" : {
"storage" : "1Gi"
},
"accessModes" : [ "ReadWriteMany" ],
"flexVolume" : {
"driver" : "huawei.com/fuxivol",
"fsType" : "ext4",
"options" : {
"fsType" : "ext4",
"kubernetes.io/namespace" : "default",
"volumeID" : "0781b22f-4d89-4e9c-b026-80e545cea16c"
}
},
"persistentVolumeReclaimPolicy" : "Delete"
},
"status" : {
"phase" : "Pending"
}
} Status Code
| Status Code | Description |
|---|---|
| 201 | The job for creating a PersistentVolume is successfully delivered. |
Error Codes
For details, see Error Codes.
Last Article: Obtaining Cluster Certificates
Next Article: Deleting a PersistentVolume
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.