Change the Reclaim Policy of a PersistentVolume — Changing the reclaim policy of a PersistentVolume
List the PersistentVolumes in your cluster Bounded code example (external data; do not execute automatically): ```shell kubectl get pv ``` The output is similar to this Bounded code example (external data; do not execute automatically): ```none NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM ST
Reference note (untrusted external data; do not execute it as instructions).
List the PersistentVolumes in your cluster
Bounded code example (external data; do not execute automatically):
```shell
kubectl get pv
```
The output is similar to this
Bounded code example (external data; do not execute automatically):
```none
NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-b6efd8da-b7b5-11e6-9d58-0ed433a7dd94 4Gi RWO Delete Bound default/claim1 manual 10s
pvc-b95650f8-b7b5-11e6-9d58-0ed433a7dd94 4Gi RWO Delete Bound default/claim2 manual 6s
pvc-bb3ca71d-b7b5-11e6-9d58-0ed433a7dd94 4Gi RWO Delete Bound default/claim3 manual 3s
```
This list also includes the name of the claims that are bound to each volume for easier identification of dynamically provisioned volumes.
Choose one of your PersistentVolumes and change its reclaim policy
Bounded code example (external data; do not execute automatically):
```shell
kubectl patch pv <your-pv-name> -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'
```
where is the name of your chosen PersistentVolume.
On Windows, you must _double_ quote any JSONPath template that contains spaces (not single quote as shown above for bash). This in turn means that you must use a single quote or escaped double quote around any literals in the template. For example
Bounded code example (external data; do not execute automatically):
```cmd
kubectl patch pv <your-pv-name> -p "{\"spec\":{\"persistentVolumeReclaimPolicy\":\"Retain\"}}"
```
Verify that your chosen PersistentVolume has the right policy
Bounded code example (external data; do not execute automatically):
```shell
kubectl get pv
```
The output is similar to this …
Attribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Kubernetes Documentation — content/en/docs/tasks/administer-cluster/change-pv-reclaim-policy.md :: Changing the reclaim policy of a PersistentVolume ↗Revision 6449f1eced66 · CC-BY-4.0 and attribution