Access Kubernetes Persistent Volume data

Viewed 2152

Is there any way to access Google cloud Kubernetes persistent volume data without using pod. I cannot start pod due to data corruption in persistent volume. Have any command line tool or any other way.

2 Answers

If you have any concerns running pod with any specific application, in that case, you can run the Ubuntu POD and attach that pod to the PVC and access the data.

There also another option to clone the PV and PVC, perform the testing, and newly created PV and PVC while the old one will work as the backup option.

For cloning PV and PVC you can also use the tool : https://velero.io/

You can also attach the PVC to the POD in read-only mode and try accessing the data.

PersistentVolume resources are cluster resources that exist independently of Pods. This means that the disk and data represented by a PersistentVolume continue to exist as the cluster changes and as Pods are deleted and recreated.

It is possible to save data from your PersistentVolume with Status: Terminating and RetainPolicy set to default(delete). Your PersistentVolumes will not be terminated until there is a pod, deployment or to be more specific a PersistentVolumeClaim using it.

The steps we took to remedy our broken state are as follows:

The first thing you want to do is to create a snapshot of your PersistentVolumes. In GKE console, go to Compute Engine -> Disks and find your volume there and create a snapshot of your volume. use

kubectl get pv | grep pvc-name

Use the snapshot to create a disk:

gcloud compute disks create name-of-disk --size=10 --source-snapshot=name-of-snapshot --type=pd-standard --zone=your-zone

At this point, stop the services using the volume and delete the volume and volume claim. Re-create the volume manually with the data from the disk and update your volume claim to target a specific volume file.

For more information refer to the links below.

Accessing file shares from Google Kubernetes Engine clusters.

Configure a Pod to Use a PersistentVolume for Storage

Related