rancher / local-path-provisioner

Dynamically provisioning persistent local storage with Kubernetes
Apache License 2.0
2.22k stars 452 forks source link

Added annotation for `local`, but volume is still `HostPath` #279

Closed loganmarchione closed 4 months ago

loganmarchione commented 1 year ago

Wanted to clarify something. I intended to use local instead of HostPath. Looking at the examples (below), the only difference is the addition of the annotation volumeType: local.

I have a PVC defined here:

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: unifi-data-pvc
  namespace: unifi
  annotations:
    volumeType: local
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: local-path-customized

However, the volume type is still HostPath. What am I doing wrong?

√ logan@kube01:~ % kubectl get pvc -n unifi
NAME             STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS            AGE
unifi-data-pvc   Bound    pvc-801c2d73-d20e-4284-8f2b-36b57a9ee695   2Gi        RWO            local-path-customized   5d17h
√ logan@kube01:~ % kubectl describe pv/pvc-801c2d73-d20e-4284-8f2b-36b57a9ee695 -n unifi 
Name:              pvc-801c2d73-d20e-4284-8f2b-36b57a9ee695
Labels:            <none>
Annotations:       pv.kubernetes.io/provisioned-by: rancher.io/local-path
Finalizers:        [kubernetes.io/pv-protection]
StorageClass:      local-path-customized
Status:            Bound
Claim:             unifi/unifi-data-pvc
Reclaim Policy:    Retain
Access Modes:      RWO
VolumeMode:        Filesystem
Capacity:          2Gi
Node Affinity:     
  Required Terms:  
    Term 0:        kubernetes.io/hostname in [kube01]
Message:           
Source:
    Type:          HostPath (bare host directory volume)
    Path:          /var/lib/rancher/k3s/storage/pvc-801c2d73-d20e-4284-8f2b-36b57a9ee695_unifi_unifi-data-pvc
    HostPathType:  DirectoryOrCreate
Events:            <none>

I'm using a custom storage class called local-path-customized so that I can add a reclaimPolicy and allowVolumeExpansion. Is that breaking my setup?

---
# Creating a custom StorageClass so that I can set some settings at the bottom
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-path-customized
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
# https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/
# https://github.com/rancher/local-path-provisioner/issues/194
reclaimPolicy: Retain
# https://github.com/rancher/local-path-provisioner/issues/107
# allowVolumeExpansion makes no difference since storage is backed by the node
allowVolumeExpansion: true
derekbit commented 1 year ago

Well..Followed your information, but the source.type is LocalVolume in my side.

# kubectl describe pv/pvc-dd72d4d9-27a9-4c18-b7ff-2fd1fc0232db
Name:              pvc-dd72d4d9-27a9-4c18-b7ff-2fd1fc0232db
Labels:            <none>
Annotations:       pv.kubernetes.io/provisioned-by: rancher.io/local-path
Finalizers:        [kubernetes.io/pv-protection]
StorageClass:      local-path
Status:            Bound
Claim:             default/local-volume-pvc
Reclaim Policy:    Delete
Access Modes:      RWO
VolumeMode:        Filesystem
Capacity:          128Mi
Node Affinity:
  Required Terms:
    Term 0:        kubernetes.io/hostname in [rancher60-worker1]
Message:
Source:
    Type:  LocalVolume (a persistent volume backed by local storage on a node)
    Path:  /mnt/local-path/pvc-dd72d4d9-27a9-4c18-b7ff-2fd1fc0232db_default_local-volume-pvc
Events:    <none>

I found your pvc doesn't have volumeType: local. Can you check your local-path-provision version again?

loganmarchione commented 1 year ago

@derekbit - My PVC has the annotation volumeType: local set (see first code block in my original comment). Is that what you're referring to?

How do you check the local-path-provisioner version? I'm on K3s v1.25.4+k3s1 which supposedly has v0.0.23.

Are you defining a separate PV in addition to a PVC? I'm only defining a PVC, without a PV. Reading through the README, maybe I'm wrong here and local-path-provisioner is working as intended and only creates a source.type of LocalVolume when defining a PV?

lanss315425 commented 7 months ago

hi @loganmarchione, have the same problem, how did you solve it? https://github.com/rancher/local-path-provisioner/issues/390

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 4 months ago

This issue was closed because it has been stalled for 5 days with no activity.