• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. API
  5. Storage Management
  6. Creating a Persistent Volume

Creating a Persistent Volume

Function

This API is used to create a persistent volume associated with cloud storage (for example, EVS, and SFS).

URI

POST /api/v1/cloudpersistentvolumes

Request

Request parameters:

Table 1 describes the request parameters.

Table 1 Parameter description

Parameter

Mandatory

Type

Description

apiVersion

Yes

String

API version. The value is fixed to v1.

kind

Yes

String

API type. The value is fixed to PersistentVolume.

metadata

Yes

Table 2

-

spec

Yes

Table 3

-

status

No

Table 4

-

Table 2 Data structure of the metadata field

Parameter

Mandatory

Type

Description

name

Yes

String

Name of the persistent volume. If the EVS volume is used, this persistent volume will be renamed to the name of the EVS volume. The SFS will not be renamed.

labels

No

String

Label of the persistent volume. A label is a key-value pair.

Table 3 Datastructure of the spec field

Parameter

Mandatory

Type

Description

flexVolume

Yes

Table 5

FlexVolume storage plug-in of Kubernetes.

accessModes

Yes

String array

Access mode of the persistent volume.

persistentVolumeReclaimPolicy

No

String

Reclaim policy of the persistent volume.

Table 4 Data structure of the status field

Parameter

Mandatory

Type

Description

accessModes

No

String array

Access mode of the persistent volume.

phase

No

String

Current status of the persistent volume.

Table 5 Data structure of the flexVolume field

Parameter

Mandatory

Type

Description

driver

Yes

String

Name of the FlexVolume storage plug-in. Set this parameter based on the storage type.

  • huawei.com/fuxivol: EVS.
  • huawei.com/fuxinfs: SFS.

fsType

Yes

String

File system type. Set this parameter based on the storage type.

  • ext4: EVS.
  • nfs: SFS.

options

Yes

Table 6

-

Table 6 Data structure of the options field

Parameter

Mandatory

Type

Description

fsType

Yes

String

File system type. Set this parameter based on the storage type.

  • ext4: EVS.
  • nfs: SFS.

region

Yes

String

Region where the cloud storage is located.

volumeID

Yes

String

Universally unique identifier (UUID) of the cloud storage.

storageType

Yes

String

Cloud storage type.

  • bs: EVS.
  • nfs: SFS.

Example request:

  • Specifying an EVS volume ID and creating a persistent volume:
    {
        "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": "eu-de",
                    "volumeID": "76e01b29-08b9-11e8-9ca5-1051722006ec",
                    "storageType": "bs"
                }
            },
            "persistentVolumeReclaimPolicy": "Delete"
        }
    }
  • Specifying an SFS volume ID and creating a persistent volume:
    {
        "apiVersion": "v1",
        "kind": "PersistentVolume",
        "metadata": {
            "labels": {
                "name": "pv-test"
            },
            "name": "pv-test"
        },
        "spec": {
            "accessModes": [
                "ReadWriteMany"
            ],
            "flexVolume": {
                "driver": "huawei.com/fuxisfs",
                "fsType": "nfs",
                "options": {
                    "fsType": "nfs ",
                    "kubernetes.io/namespace": "default",
                    "region": "eu-de",
                    "volumeID": "56e01b29-02b9-128-9ca5-1051722006ec",
                    "storageType": "nfs"
                }
            },
            "persistentVolumeReclaimPolicy": "Delete"
        }
    }

Response

Response parameters:

For the description of the response parameters, see Table 1.

Example response:

{
    "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": "Recycle"
    },
    "status": {
        "phase": "Pending"
    }
}

Status Code

Table 7 describes the status code of the API.

Table 7 Statuscode

Status Code

Description

201

The job for creating a persistent volume is successfully delivered.