canonical / microk8s-core-addons

Core MicroK8s addons
Apache License 2.0
40 stars 33 forks source link

nfs pv/pvc over NFS ignores ReclaimPolicy, and always clean up folder in the NFS server #99

Open sHaggYcaT opened 2 years ago

sHaggYcaT commented 2 years ago

Summary

nfs pv/pvc over NFS, as well as storageClass ignores ReclaimPolicy, and always clean up folder in the NFS server, after deleting pvc

I tried to use following:

  1. reclaimPolicy: Retain in the StorageClass, related to PVC, created in PV over NFS
  2. provisioner: nfs in the StorageClass
  3. provisioner: kubernetes.io/no-provisioner in the StorageClass
  4. Do not use StorageClass at all
  5. persistentVolumeReclaimPolicy: Recycle in the PV

Anyway, it always happened - after deleting PVC, microk8s always deletes folder spec.nfs.path which described in PV's yaml config

What Should Happen Instead?

I expected, that after deleting PVC, microk8s do not deletes folder in the NFS server

Reproduction Steps

For example, you can use configs like this:

cat pv.yml 
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs4smb
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
allowVolumeExpansion: true
volumeBindingMode: Immediate

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: samba-mapping4nfs
  namespace: samba
spec:
  volumeMode: Filesystem
  storageClassName: nfs4smb
  capacity:
    storage: 500Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Recycle
  mountOptions:
    - rw
    - rsize=6476
    - wsize=64768
    - noatime  
    - nfsvers=4.2
  nfs:
    path: /tank/compressed/windows/
    server: 10.11.17.10
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: compressed
  namespace: samba
spec:
  storageClassName: nfs4smb
  accessModes:
  - ReadWriteMany      
  resources:
     requests:
       storage: 500Gi   
  volumeName: samba-mapping4nfs

I use a default snap package: microk8s v1.24.3 3597 1.24/stable canonical✓ classic

neoaggelos commented 1 year ago

FYI; I don't expect this behaviour be specific to MicroK8s, but rather the way Kubernetes deals with PVs and PVCs. Perhaps a better place to report this would be the https://github.com/kubernetes/kubernetes repo.