• 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

Standard object's metadata.

spec

Yes

Table 3

Spec defines a specification of a persistent volume owned by the cluster. Provisioned by an administrator.

status

No

Table 4

Status represents the current information/status for the persistent volume. Populated by the system. Read-only.

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.

Options:

  • ReadWriteOnce: can be read and written by a single node.
  • ReadOnlyMany: can only be read by multiple nodes.
  • ReadWriteMany: can be read and written by multiple nodes.

accessModes

Yes

String array

Access mode of the persistent volume.

persistentVolumeReclaimPolicy

No

String

What happens to a persistent volume when released from its claim. Valid options are Retain (default) and Recycle. Recycling must be supported by the volume plugin underlying this 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:

Table 7 Parameter description

Parameter

Type

Description

apiVersion

String

API version. The value is fixed to v1.

kind

String

API type. The value is fixed to PersistentVolume.

metadata

Table 8

Standard object's metadata.

spec

Table 9

Spec defines a specification of a persistent volume owned by the cluster. Provisioned by an administrator.

status

Table 10

Status represents the current information/status for the persistent volume. Populated by the system. Read-only.

Table 8 Data structure of the metadata field

Parameter

Type

Description

annotations

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.

creationTimestamp

String

A timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. Populated by the system. Read-only. Null for lists.

NOTE:

This field is automatically generated. Do not assign any value to this field. Otherwise, API calls would fail.

labels

String

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

name

String

Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated.

0 characters < name length ≤ 253 characters.

The name must be a regular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

resourceVersion

String

Specific resourceVersion to which this reference is made, if any.

selfLink

String

A URL representing this object. Populated by the system. Read-only.

NOTE:

This field is automatically generated. Do not assign any value to this field. Otherwise, API calls would fail.

uid

String

UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations. Populated by the system. Read-only.

NOTE:

This field is automatically generated. Do not assign any value to this field. Otherwise, API calls would fail.

Table 9 Datastructure of the spec field

Parameter

Type

Description

flexVolume

Table 11

FlexVolume storage plug-in of Kubernetes.

Options:

  • ReadWriteOnce: can be read and written by a single node.
  • ReadOnlyMany: can only be read by multiple nodes.
  • ReadWriteMany: can be read and written by multiple nodes.

accessModes

String array

Access mode of the persistent volume.

capacity

Object

Actual resources and capacity of the persistent volume.

persistentVolumeReclaimPolicy

String

What happens to a persistent volume when released from its claim. Valid options are Retain (default) and Recycle. Recycling must be supported by the volume plugin underlying this persistent volume.

Table 10 Data structure of the status field

Parameter

Type

Description

phase

String

Current status of the persistent volume.

Table 11 Data structure of the flexVolume field

Parameter

Type

Description

driver

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

String

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

  • ext4: EVS.
  • nfs: SFS.

options

Table 12

-

Table 12 Data structure of the options field

Parameter

Type

Description

fsType

String

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

  • ext4: EVS.
  • nfs: SFS.

region

String

Region where the cloud storage is located.

volumeID

String

Universally unique identifier (UUID) of the cloud storage.

Example response:

{
    "apiVersion": "v1",
    "kind": "PersistentVolume",
    "metadata": {
        "annotations": {
            "pv.kubernetes.io/namespace": "default"
        },
        "creationTimestamp": "2019-05-09T07:08:57Z",
        "labels": {
            "name": "volume-dwb-test"
        },
        "name": "volume-dwb-test",
        "resourceVersion": "2179",
        "selfLink": "/api/v1/persistentvolumes/volume-dwb-test",
        "uid": "500b1d85-7229-11e9-bc40-fa163e8e6bf0"
    },
    "spec": {
        "accessModes": [
            "ReadWriteOnce"
        ],
        "capacity": {
            "storage": "10Gi"
        },
        "flexVolume": {
            "driver": "huawei.com/fuxinfs",
            "fsType": "ext4",
            "options": {
                "fsType": "ext4",
                "region": "eu-de",
                "volumeID": "46f9553c-4aaf-46e9-911b-9e7751e5ae9a"
            }
        },
        "persistentVolumeReclaimPolicy": "Recycle"
    },
    "status": {
        "phase": "Pending"
    }
}

Status Code

Table 13 describes the status code of the API.

Table 13 Statuscode

Status Code

Description

201

The job for creating a persistent volume is successfully delivered.