• 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

Standard object's metadata.

spec

Yes

Table 4

Spec defines the desired characteristics of a volume requested by a pod author.

status

No

Table 5

Status represents the current information/status of a persistent volume claim.

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.

namespace

Yes

String

Namespace where the persistent volume claim is located.

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.

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.
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:

Table 6 Parameter description

Parameter

Type

Description

apiVersion

String

API version. The value is fixed to v1.

kind

String

API type. The value is fixed to PersistentVolumeClaim.

metadata

Table 3

Standard object's metadata.

spec

Table 4

Spec defines the desired characteristics of a volume requested by a pod author.

status

Table 5

Status represents the current information/status of a persistent volume claim.

Table 7 Data structure of the metadata field

Name

Type

Description

annotations

Map[string]string

An unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects.

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.

enable

Boolean

Enable identify whether the resource is available.

labels

Map[string]string

Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services.

name

String

Name of the persistent volume claim.

namespace

String

Namespace defines the space within each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. Must be a DNS_LABEL. Cannot be updated.

0 characters < namespace length ≤ 63 characters.

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

resourceVersion

String

An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. Populated by the system. Read-only. Value must be treated as opaque by clients.

NOTE:

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

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 8 Data structure of the spec field

Parameter

Type

Description

accessModes

String array

AccessModes contains the desired access modes the volume should have.

resources

Table 9

Resources represents the minimum resources the volume should have.

volumeName

String

VolumeName is the binding reference to the PersistentVolume backing this claim.

This parameter is required when you use flexVolume to create a PV for an existing cloud storage.

Table 9 Data structure of the resources field

Parameter

Type

Description

requests

Object

Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value.

NOTE:

Except parameter storage, the other parameters (such as CPU and memory) are invalid.

Table 10 Data structure of the status field

Parameter

Type

Description

phase

String

Phase represents the current phase of PersistentVolumeClaim.

Example response:

{
    "apiVersion": "v1",
    "kind": "PersistentVolumeClaim",
    "metadata": {
        "annotations": {
            "volume.beta.kubernetes.io/storage-class": "sata",
            "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol"
        },
        "creationTimestamp": "2019-05-09T07:19:48Z",
        "enable": true,
        "labels": {
            "failure-domain.beta.kubernetes.io/region": "eu-de",
            "failure-domain.beta.kubernetes.io/zone": "eu-de-02"
        },
        "name": "csms-dev-boce",
        "namespace": "default",
        "resourceVersion": "3558",
        "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/csms-dev-boce",
        "uid": "d40f5fb9-722a-11e9-bc40-fa163e8e6bf0"
    },
    "spec": {
        "accessModes": [
            "ReadWriteOnce"
        ],
        "resources": {
            "requests": {
                "storage": "10Gi"
            }
        },
        "volumeName": "volume-test"
    },
    "status": {
        "phase": "Pending"
    }
}

Status Code

Table 11 describes the status code of the API.

Table 11 Statuscode

Status Code

Description

201

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