• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. Kubernetes API
  5. PersistentVolume
  6. Creating a PersistentVolume

Creating a PersistentVolume

Function

This API is used to create a PersistentVolume object.

URI

POST /api/v1/persistentvolumes

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

pretty

No

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

Request

Request parameters:

Table 2 Request parameter

Parameter

Mandatory

Type

Description

apiVersion

Yes

String

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values.

kind

Yes

String

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase.

metadata

Yes

Table 11

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

Parameter

Mandatory

Type

Description

accessModes

Yes

String Array

Access mode.

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.

capacity

Yes

Object

A description of the persistent volume's resources and capacity.

claimRef

No

Table 5

ClaimRef is part of a bi-directional binding between PersistentVolume and PersistentVolumeClaim. Expected to be non-nil when bound. claim. VolumeName is the authoritative bind between PV and PVC.

NOTE:

Select claimRef or hostpath to use a storage. You are advised to use claimRef to reference PVC for dynamically creating a storage or attaching an EVS disk or SFS file system on the GUI.

hostPath

No

Table 6

HostPath represents a directory on the host. Provisioned by a developer or tester. This is useful for single-node development and testing only! On-host storage is not supported in any way and WILL NOT WORK in a multi-node cluster.

NOTE:

Select claimRef , flexVolume or hostpath to use a storage. You are advised to use claimRef to reference PVC for dynamically creating a storage or attaching an EVS disk or SFS file system on the GUI.

flexVolume

No

Table 7

FlexVolume storage plug-in of Kubernetes.

persistentVolumeReclaimPolicy

Yes

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.

storageClassName

No

String

Name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.

Table 4 Data structure of the status field

Parameter

Mandatory

Type

Description

message

No

String

A human-readable message indicating details about why the volume is in this state.

phase

No

String

Phase indicates if a volume is available, bound to a claim, or released by a claim.

reason

No

String

Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.

Table 5 Data structure of the claimRef field

Parameter

Mandatory

Type

Description

apiVersion

No

String

API version of the referent.

fieldPath

No

String

If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: "spec.containers{name}" (where "name" refers to the name of the container that triggered the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.

kind

No

String

Kind of the referent.

name

No

String

Name of the referent.

namespace

No

String

Namespace of the referent.

resourceVersion

No

String

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

uid

No

String

UID of the referent.

Table 6 Data structure of the hostPath field

Parameter

Mandatory

Type

Description

path

No

String

Path of the directory on the host.

Table 7 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: NFS

fsType

Yes

String

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

  • ext4: EVS.
  • nfs: SFS.

options

Yes

Table 8

-

Table 8 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

kubernetes.io/namespace

Yes

String

Namespace of the PV, which shoud be filled with "default".

volumeID

Yes

String

UUID of the cloud storage.

deviceMountPath

No

String

Shared path of the SFS storage.

Example request:

{
    "apiVersion": "v1",
    "kind": "PersistentVolume",
    "metadata": {
        "labels": {
            "name": "pv-test"
        },
        "name": "pv-test"
    },
    "spec": {
        "accessModes": [
            "ReadWriteMany"
        ],
        "capacity": {
            "storage": "1Gi"
        },
        "hostPath": {
            "path": "/home"
        },
        "persistentVolumeReclaimPolicy": "Recycle"
    }
}

Response

Response parameters:

For the description about response parameters, see 15.2-Table2 Request parameter.

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"
        },
        "hostPath": {
            "path": "/home"
        },
        "accessModes": [
            "ReadWriteMany"
        ],
        "persistentVolumeReclaimPolicy": "Recycle"
    },
    "status": {
        "phase": "Pending"
    }
}

Status Code

Table 9 describes the status code of this API.

Table 9 Status code

Status Code

Description

201

The request has been fulfilled, resulting in the creation of a new resource.

For the description about status codes, see Status Codes.