• 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 Claim

Creating a Persistent Volume Claim

Function

This API is used to create a persistent volume claim associated with cloud storage, for example, Elastic Volume Service (EVS), and Scalable File Storage (SFS), in a specified namespace.

It is good practice to use proprietary or Kubernetes-native APIs to manage your resources in pairs. For example: If the proprietary API described in section 5.2.1 is used to create a persistent volume claim, you are advised to use the proprietary API described in section 5.2.2 (other than Kubernetes-native API described in section 5.9.2) to delete the created persistent volume claim.This restriction also applies to the APIs used for creating and deleting persistent volumes.

URI

POST /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims

Table 1 describes the parameters of the API.

Table 1 Parameter description

Parameter

Mandatory

Description

namespace

Yes

Namespace where the persistent volume claim is located.

Request

Request parameters:

Table 2 describes the request parameters.

Table 2 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 PersistentVolumeClaim.

metadata

Yes

Table 3

-

spec

Yes

Table 4

-

status

No

Table 5

-

Table 3 Data structure of the metadata field

Parameter

Mandatory

Type

Description

name

Yes

String

Name of the persistent volume claim.

labels

No

String

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

Table 4 Data structure of the spec field

Parameter

Mandatory

Type

Description

volumeName

No

String

Name of the persistent volume bound to the persistent volume claim.

NOTE:

If volumeID has been configured, the value of this parameter is invalid.

volumeID

No

String

ID of the cloud storage volume.

storageType

No

String

Cloud storage type. This parameter is used together with volumeID. That is, storageType is configurable only when volumeID has been configured.

  • bs: EVS.
  • nfs: SFS.

accessModes

Yes

String array

Access mode of the persistent volume.

Table 5 Data structure of the status field

Parameter

Mandatory

Type

Description

accessModes

No

String array

Access mode of the persistent volume.

capacity

No

Object

Actual resources and capacity of the persistent volume.

phase

No

String

Current status of the persistent volume claim.

Example request:

  • Specifying an EVS volume ID and creating a persistent volume claim:
    {
        "apiVersion": "v1",
        "kind": "PersistentVolumeClaim",
        "metadata": {
            "name": "csms-dev-create",
            "namespace": "default"
        },
        "spec": {
            "volumeID": "86b29e16-23db-11e7-9c83-fa163ec08232",
            "storageType": "bs",
            "accessModes": [
                "ReadWriteMany"
            ]
        }
    }
  • Specifying an SFS volume ID and creating a persistent volume claim:
    {
        "apiVersion": "v1",
        "kind": "PersistentVolumeClaim",
        "metadata": {
            "name": "csms-dev-create",
            "namespace": "default"
        },
        "spec": {
            "volumeID": "86b29e16-23db-11e7-9c83-fa163ec08232",
            "storageType": "nfs",
            "accessModes": [
                "ReadWriteMany"
            ]
        }
    }

Response

Response parameters:

For details about the response parameters, see Table 2.

Example response:

{
    "kind": "PersistentVolumeClaim",
    "apiVersion": "v1",
    "metadata": {
        "name": " csms-dev-create ",
        "namespace": "default",
        "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0",
        "uid": "86b29e16-23db-11e7-9c83-fa163ec08232",
        "resourceVersion": "1793115",
        "creationTimestamp": "2017-04-18T02:05:42Z"
    },
    "spec": {
        "volumeName": "csms-dev-create ",
        "accessModes": [
            "ReadWriteMany"
        ],
        "resources": {
            "requests": {
                "storage": "1Gi"
            }
        }
    },
    "status": {
        "phase": "Pending",
        "accessModes": [
            "ReadWriteMany"
        ]
    }
}

Status Code

Table 6 describes the status code of the API.

Table 6 Statuscode

Status Code

Description

201

The job for creating a persistent volume claim is successfully delivered.