PVC not rebinding after chart reinstall

1/21/2021

I've got a bare-metal K8S setup. The setup has a rook/ceph as it's storage operator and the applications claim a PVC from it. The claiming works great. for all intents - these are the versions:

rook/ceph
  tag: v1.4.2
ceph/ceph
  tag: v15.2.4 

Until... suppose a Jenkins deployment: this being a snippet from the Deployment.yaml for the volumes.

  volumes:
    - name: some-apps
      hostPath:
        path: {{ .Values.someapps_hostPath }}
    - name: "jenkins-home"
      persistentVolumeClaim:
        claimName: {{ $fullName }}

This is the snippet for the pvc:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: "{{ $fullName }}"
  labels:
    app: {{ $fullName }}
    chart: "{{ $chartName }}-{{ $chartVersion }}"
    release: "{{ $releaseName }}"
    heritage: "{{ $releaseService }}"
spec:
  accessModes:
    - {{ $accessMode | quote }}
  resources:
    requests:
      storage: {{ $size | quote }}
{{- if $storageClass }}
{{- if (eq "-" $storageClass) }}
  storageClassName: ""
{{- else }}
  storageClassName: {{ $storageClass | quote }}
{{- end }}
{{- end }}

looks completely normal. now when i do " helm uninstall jenkins-test" and then "helm install jenkins-test /path/to/chart/" i dont see any of the my data that i used for the PVC.

instead i see this in the "describe pvc/pv"

NAME                                    STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
jenkins-test                            Bound    pvc-264373e7-6b26-4205-9b5c-aed1d3fee940   3Gi        RWX            ceph           2m36s_
[root@infra-k8s-master1 test]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS     CLAIM                                           STORAGECLASS   REASON   AGE
pvc-264373e7-6b26-4205-9b5c-aed1d3fee940   3Gi        RWX            Retain           Bound      default/jenkins-test                            ceph                    2m43s
pvc-45ce065e-84b7-4c56-9e56-d9966dfe4634   3Gi        RWX            Retain           Released   default/jenkins-test                            ceph                    22h
pvc-5089b785-ad3c-464b-bc01-51b86af3f5df   3Gi        RWX            Retain           Released   default/jenkins-test                            ceph                    23m

So far, i did take an existing PVC - did kubectl edit pv ## and removed the claimRef field and data then the PVC was status:Available and rebound correctly and data preserved but this is all manual work. i was expecting something to completely automatic when i redeploy a chart with the same pvc naming and claiming.

Does each "reinstall" of the same chart deploy an entirely new set of pvc?

AFAIK - when using PVC and Provisioner like Ceph, it should re-bind the existing PVC to the redeployed chart.

Edit: The chart is Deployment and not StatefulSet - if that matters - with 1 replica

Am I missing something in the concept? maybe I missing something? I'm puzzled here. thanks for any information!

-- dtuaev25
ceph
kubernetes
kubernetes-helm

2 Answers

1/21/2021

You have "Reclaim Policy=Retain" for these volumes.

When the PersistentVolumeClaim is deleted, the PersistentVolume still exists and the volume is considered "released". reference

-- Anton
Source: StackOverflow

7/8/2021

Can you check to see if you have any Finalizers attached as annotations to the PVC/PV which would prevent you from deleting them?

-- Vincent Rodomista
Source: StackOverflow