• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. PersistentVolume (Native Kubernetes APIs)
  5. Replacing a Specified PersistentVolume

Replacing a Specified PersistentVolume

Function

This API is used to replace a specified PersistentVolume object.

The following fields can be updated:

  • metadata.labels
  • metadata.generateName
  • spec.accessModes
  • spec.capacity
  • spec.hostPath.path
  • spec.persistentVolumeReclaimPolicy
  • spec.nfs.path
  • spec.nfs.server
  • spec.nfs.readOnly
  • spec.hwsElasticVolumeService.volumeID
  • spec.hwsElasticVolumeService.fsType
  • spec.hwsElasticVolumeService.readOnly

URI

PUT /api/v1/persistentvolumes/{name}

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

name

Yes

Name of the PersistentVolume.

pretty

No

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

Request

Request parameters:

For the description about request parameters, see the parameter description in Table 2.

Example request:

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

Response

Response parameters:

For the description about response parameters, see the parameter description in Table 2.

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": "174358",
        "creationTimestamp": "2018-01-22T03:11:03Z",
        "labels": {
            "name": "test"
        },
        "enable": true
    },
    "spec": {
        "capacity": {
            "storage": "1Gi"
        },
        "hostPath": {
            "path": "/home"
        },
        "accessModes": [
            "ReadWriteOnce"
        ],
        "persistentVolumeReclaimPolicy": "Recycle"
    },
    "status": {
        "phase": "Available"
    }
}

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

200

This operation succeeds, and a PersistentVolume resource object is returned.

For the description about status codes, see Status Codes.