Openebs: OpenEBS Volume - support for retain and recycle reclaim policy.

Created on 4 Oct 2017  路  3Comments  路  Source: openebs/openebs

Kubernetes supports the following three relcaim policies:

There may be some usecases where Delete may not be the best reclaim policy. The user should be able to specify which relcaim policy to use via the storage class.

arevolumprovisioning kinenhancement no-issue-activity summerhack

Most helpful comment

The retain policy can be used for a given PVC using the following manual steps.

(a) Create a StorageClass with retain policy.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: jiva-retain
  annotations:
    openebs.io/cas-type: jiva
    cas.openebs.io/config: |
      - name: ReplicaCount
        value: "3"
provisioner: openebs.io/provisioner-iscsi
reclaimPolicy: Retain
---

(b) Create a PVC

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jiva-vol1-retain-claim
spec:
  storageClassName: jiva-retain
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4G

(c) A PV will be created with retain policy.

kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM                           STORAGECLASS   REASON    AGE
pvc-46387102-567b-11e9-b9b1-42010a800110   4G         RWO            Retain           Bound    default/jiva-vol1-retain-claim   jiva-retain              41m

(d) Delete PVC, check that PV still exists in Released state.

kubectl describe pv
Name:            pvc-46387102-567b-11e9-b9b1-42010a800110
Labels:          openebs.io/cas-type=jiva
                 openebs.io/storageclass=jiva-retain
                 pvc-name=jiva-vol1-retain-claim
Annotations:     openEBSProvisionerIdentity=gke-kmova-helm-default-pool-17eeeaaa-ldm9
                 openebs.io/cas-type=jiva
                 pv.kubernetes.io/provisioned-by=openebs.io/provisioner-iscsi
StorageClass:    jiva-retain
Status:          Released
Claim:           default/jiva-vol1-retain-claim
Reclaim Policy:  Retain
Access Modes:    RWO
Capacity:        4G

(e) To reuse the above PV, modify the PVC YAML spec to include volumeName pointing to above PVC.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jiva-vol1-retain-claim
spec:
  storageClassName: jiva-retain
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4G
  volumeName: pvc-46387102-567b-11e9-b9b1-42010a800110

(f) The PVC will be in pending state, but attached to the previous PV.

kubectl describe pvc
Name:          jiva-vol1-retain-claim
Namespace:     default
StorageClass:  jiva-retain
Status:        Pending
Volume:        pvc-46387102-567b-11e9-b9b1-42010a800110
Labels:        <none>
Annotations:   kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{
},"name":"jiva-vol1-retain-claim","namespace":"default"},"spec":{"accessMo...
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      0
Access Modes:  
Events:        <none>

(g) Patch the PV - to refer to the new PVC.

Get the UID of the PVC

kubectl get pvc jiva-vol1-retain-claim -o=custom-columns=NAME:.metadata.name,UID:.metadata.uid
NAME                     UID
jiva-vol1-retain-claim   a208ba3d-5681-11e9-b9b1-42010a800110

Patch the PVC claimRef UID

kubectl patch pv pvc-46387102-567b-11e9-b9b1-42010a800110 --patch '{"spec": {"claimRef": {"uid": "a208ba3d-5681-11e9-b9b1-42010a800110"}}}'

(h) Wait for the PVC to show the capacity. Takes about 5s to 10s.

kubectl get pvc
NAME                     STATUS    VOLUME                                     CAPACITY   ACCESS MODES  STORAGECLASS   AGE
jiva-vol1-retain-claim   Bound     pvc-46387102-567b-11e9-b9b1-42010a800110   4G         RWO           jiva-retain    3m

All 3 comments

Retain policy for dynamic provisioning is under review here https://github.com/kubernetes-incubator/external-storage/issues/326

The retain policy can be used for a given PVC using the following manual steps.

(a) Create a StorageClass with retain policy.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: jiva-retain
  annotations:
    openebs.io/cas-type: jiva
    cas.openebs.io/config: |
      - name: ReplicaCount
        value: "3"
provisioner: openebs.io/provisioner-iscsi
reclaimPolicy: Retain
---

(b) Create a PVC

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jiva-vol1-retain-claim
spec:
  storageClassName: jiva-retain
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4G

(c) A PV will be created with retain policy.

kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM                           STORAGECLASS   REASON    AGE
pvc-46387102-567b-11e9-b9b1-42010a800110   4G         RWO            Retain           Bound    default/jiva-vol1-retain-claim   jiva-retain              41m

(d) Delete PVC, check that PV still exists in Released state.

kubectl describe pv
Name:            pvc-46387102-567b-11e9-b9b1-42010a800110
Labels:          openebs.io/cas-type=jiva
                 openebs.io/storageclass=jiva-retain
                 pvc-name=jiva-vol1-retain-claim
Annotations:     openEBSProvisionerIdentity=gke-kmova-helm-default-pool-17eeeaaa-ldm9
                 openebs.io/cas-type=jiva
                 pv.kubernetes.io/provisioned-by=openebs.io/provisioner-iscsi
StorageClass:    jiva-retain
Status:          Released
Claim:           default/jiva-vol1-retain-claim
Reclaim Policy:  Retain
Access Modes:    RWO
Capacity:        4G

(e) To reuse the above PV, modify the PVC YAML spec to include volumeName pointing to above PVC.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jiva-vol1-retain-claim
spec:
  storageClassName: jiva-retain
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4G
  volumeName: pvc-46387102-567b-11e9-b9b1-42010a800110

(f) The PVC will be in pending state, but attached to the previous PV.

kubectl describe pvc
Name:          jiva-vol1-retain-claim
Namespace:     default
StorageClass:  jiva-retain
Status:        Pending
Volume:        pvc-46387102-567b-11e9-b9b1-42010a800110
Labels:        <none>
Annotations:   kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{
},"name":"jiva-vol1-retain-claim","namespace":"default"},"spec":{"accessMo...
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      0
Access Modes:  
Events:        <none>

(g) Patch the PV - to refer to the new PVC.

Get the UID of the PVC

kubectl get pvc jiva-vol1-retain-claim -o=custom-columns=NAME:.metadata.name,UID:.metadata.uid
NAME                     UID
jiva-vol1-retain-claim   a208ba3d-5681-11e9-b9b1-42010a800110

Patch the PVC claimRef UID

kubectl patch pv pvc-46387102-567b-11e9-b9b1-42010a800110 --patch '{"spec": {"claimRef": {"uid": "a208ba3d-5681-11e9-b9b1-42010a800110"}}}'

(h) Wait for the PVC to show the capacity. Takes about 5s to 10s.

kubectl get pvc
NAME                     STATUS    VOLUME                                     CAPACITY   ACCESS MODES  STORAGECLASS   AGE
jiva-vol1-retain-claim   Bound     pvc-46387102-567b-11e9-b9b1-42010a800110   4G         RWO           jiva-retain    3m

Issues go stale after 90d of inactivity.

Was this page helpful?
0 / 5 - 0 ratings