Updating a Specified PersistentVolume

Function

This API is used to update a PersistentVolume.

The following fields can be updated:

  • metadata.labels
  • metadata.generateName
  • spec.accessModes
  • spec.capacity
  • spec.persistentVolumeReclaimPolicy

URI

PATCH /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 the Content-Type field, see Patch Request Method Operation Description.

Example request:

Content-Type: application/json-patch+json
[
    {
        "op": "add",
        "path": "/spec/persistentVolumeReclaimPolicy",
        "value": "Retain"
    }
]

Response

Response parameters:

For the description about response parameters, see Table 2.

Example response:

{
    "kind": "PersistentVolume",
    "apiVersion": "v1",
    "metadata": {
        "name": "pv-test-03",
        "namespace": "default",
        "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test-03",
        "uid": "45eb3e76-9212-11e8-8cd0-fa163e082286",
        "resourceVersion": "5690537",
        "creationTimestamp": "2018-07-28T02:59:41Z",
        "labels": {
            "failure-domain.beta.kubernetes.io/region": "cn-north-4",
            "failure-domain.beta.kubernetes.io/zone": "cn-north-4a",
            "name": "pv-test-03"
        },
        "annotations": {
            "volume.beta.kubernetes.io/storage-class": "sata",
            "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol"
        }
    },
    "spec": {
        "capacity": {
            "storage": "20Gi"
        },
        "hostPath": {
            "path": "/home",
            "type": ""
        },
        "accessModes": [
            "ReadWriteMany"
        ],
        "persistentVolumeReclaimPolicy": "Delete"
    },
    "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 error status codes, see Status Code.