How to check current reclaim policy?

089

To check the current reclaim policy of a PersistentVolume (PV) in Kubernetes, you can use the kubectl get command with the -o option to output the details in a specific format. Here are a couple of ways to do this:

Method 1: Using kubectl get pv

You can retrieve the details of a specific PV, including its reclaim policy, by running the following command:

kubectl get pv <pv-name> -o yaml

Replace <pv-name> with the name of your PersistentVolume. This command will display the full YAML definition of the PV, and you can look for the persistentVolumeReclaimPolicy field in the output.

Method 2: Using kubectl describe pv

Alternatively, you can use the kubectl describe command to get a more human-readable output:

kubectl describe pv <pv-name>

This command will provide detailed information about the PV, including the reclaim policy, under the Reclaim Policy section.

Example Output

When you run either of the above commands, you should see output similar to this:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-pv
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  ...

In this example, the reclaim policy is set to Retain.

By using these methods, you can easily check the current reclaim policy of a PersistentVolume in your Kubernetes cluster.

0 Comments

no data
Be the first to share your comment!