On occasions, an Openshift/Kubernetes admin/user wants to make a clone of a Persistent Volume (PV) in a cluster for satisfying some of the requirements of the application pod. The standard way of doing ‘cloning’ is still under development in Kubernetes, however, there are some techniques that can be used to create a clone of a PV. In this blog article, I would like to discuss one method which is nothing but taking a clone via an annotation in the Persistent Volume claim object, very convenient, isn’t it?
As a user you don’t need to know what’s happening in the backend, but you will be given a new PVC object which has the contents of the PVC you were referencing in the annotation.
Even though the process is detailed in the demo video, I would like to mention the core step here:
Suppose you have a PVC called `claim1` and would like to take a clone of this volume, the only step you need to do here is to create a new PVC file with an annotation called `”k8s.io/CloneRequest”: “claim1” ` in it as shown below.
[terminal]
[root@node]# oc get pvc
VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE NAME STATUS
pvc-8cc1e066-32c0-11e8-915c-5254001e667e 1Gi RWX glusterfile 2m claim1 Bound
[root@node]# cat claim1clone.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: claim1clone
annotations:
volume.beta.kubernetes.io/storage-class: “glusterfile”
“k8s.io/CloneRequest”: “claim1”
spec:
accessModes:
– ReadWriteMany
resources:
requests:
storage: 1Gi
[/terminal]
Cool ? Isnt it ? see it in action by demo video:
Demo
I hope this help some admins/users, if so please try it out.
ps # As always please ask your questions or provide feedback, I value it a lot!
Copyright secured by Digiprove © 2018-2020 Humble Chirammal