Creating a PersistentVolumeClaim

Function

This API is used to dynamically create a PersistentVolumeClaim (PVC). If no storage resources are available, a storage resource is automatically created based on the request for creating a PVC.

Currently, EVS and SFS volumes can be created. The spec.storageClassName parameter specifies the volume type. It has the following values:

  • sata: common I/O EVS volume
  • sas: high I/O EVS volume
  • ssd: ultra-high I/O EVS volume
  • nfs-rw: Network File System (NFS) volume

If spec.storageClassName is not specified, you can specify volume.beta.kubernetes.io/storage-class in metadata.annotations. The two parameters have the same values. Specify either of the two parameters.

To create an encrypted EVS volume, add the paas.storage.io/cryptKeyId field to metadata.annotations. To create an encrypted SFS volume, add the paas.storage.io/cryptKeyId, paas.storage.io/cryptAlias, and paas.storage.io/cryptDomainId fields to metadata.annotations.

URI

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

Table 1 Path parameter

Parameter

Description

namespace

Object name and auth scope, such as for teams and projects.

Table 2 Query parameters

Parameter

Mandatory

Description

pretty

No

If 'true', then the output is pretty printed.

Request

Request parameters

For details, see Table 92.

Example request

  • Create a 10-GB encrypted EVS volume of the sata type.
    {
        "apiVersion": "v1",
        "kind": "PersistentVolumeClaim",
        "metadata": {
            "annotations": {
                "paas.storage.io/cryptKeyId":"ee9b610c-e356-11e9-aadc-d0efc1b3bb6b",
                "volume.beta.kubernetes.io/storage-class": "sata"
            },
            "name": "pvc-test",
            "namespace": "test-namespace"
        },
        "spec": {
            "accessModes": [
                "ReadWriteMany"
            ],
            "resources": {
                "requests": {
                    "storage": "10Gi"
                }
            }
        }
    }
  • Create a 10-GB encrypted SFS volume.
    {
        "apiVersion": "v1",
        "kind": "PersistentVolumeClaim",
        "metadata": {
            "annotations": {
               "paas.storage.io/cryptKeyId":"ee9b610c-e356-11e9-aadc-d0efc1b3bb6b",
               "paas.storage.io/cryptAlias":"sfs/default",
               "paas.storage.io/cryptDomainId":"d6912480-c3d6-4e9e-8c70-38afeea434c3",
               "volume.beta.kubernetes.io/storage-class": "nfs-rw"
            },
            "name": "pvc-test",
            "namespace": "test-namespace"
        },
        "spec": {
            "accessModes": [
                "ReadWriteMany"
            ],
            "resources": {
                "requests": {
                    "storage": "10Gi"
                }
            }
        }
    }

Response

Response parameters

For the description about response parameters, see Table 92.

Example response

{
    "kind": "PersistentVolumeClaim",
    "apiVersion": "v1",
    "metadata": {
        "name": "pvc-test",
        "namespace": "test-namespace",
        "selfLink": "/api/v1/namespaces/ns-test/persistentvolumeclaims/pvc-test",
        "uid": "58d15f3e-efbd-11e8-8950-501d934409f3",
        "resourceVersion": "28156856",
        "creationTimestamp": "2018-11-24T07:48:35Z",
        "labels": {
            "app": "evs"
        },
        "annotations": {
            "paas.storage.io/cryptKeyId": "ee9b610c-e356-11e9-aadc-d0efc1b3bb6b",
            "pv.kubernetes.io/bind-completed": "yes",
            "pv.kubernetes.io/bound-by-controller": "yes",
            "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol"
        },
        "finalizers": [
            "kubernetes.io/pvc-protection"
        ]
    },
    "spec": {
        "accessModes": [
            "ReadWriteMany"
        ],
        "resources": {
            "requests": {
                "storage": "10Gi"
            }
        },
        "volumeName": "pvc-58d15f3e-efbd-11e8-8950-501d934409f3",
        "storageClassName": "sata"
    },
    "status": {
        "phase": "Bound",
        "accessModes": [
            "ReadWriteMany"
        ],
        "capacity": {
            "storage": "10Gi"
        }
    }
}

Status Code

Table 3 describes the status code of this API.

Table 3 Status code

Status Code

Description

201

Created

200

OK

203

Accepted

For more status codes, see Status Codes.