2

All,

Is there a way to find the nodes associated with Persistent Volume Claim.

> kubectl get pvc -n namespace

gives me the list of Persistent Volume Claims. But I need the node also to which each of the Claim is associated with.

Even describing the PVC does not give me the node

kubectl describe pvc pvcname -n namespace

Thanks,
grajee

Gopinath Rajee
  • 400
  • 5
  • 20

1 Answers1

3
  • whenever PVC is used by a POD , kubernetes creates a object called volumeattachment which contains the node information where the pvc is attached.
   - kubectl get volumeattachements | grep <pv name> // to get the volumeattachment name
   - kubectl describe volumeattachment <volumeattachment name from above command> | grep -i 'node name'
Lei Yang
  • 3,970
  • 6
  • 38
  • 59
confused genius
  • 2,876
  • 2
  • 16
  • 29
  • is it possible to get binding pod names? – Lei Yang Jul 14 '21 at 04:45
  • i could not find any direct way of finding it , but workaround is ```kubectl get pvc --all-namespaces -o json | jq -j '.items[] | "\(.metadata.namespace), \(.metadata.name), \(.spec.volumeName)\n"' | grep ``` – confused genius Jul 14 '21 at 04:54
  • This appears not to work anymore / or maybe doesn't work in some cases. At least for me, this always comes back empty, also, considering you fix the typo: `volumeattachments`. – wvxvw Jul 20 '23 at 16:48
  • Do you get any output for `kubectl get volumeattachments` – confused genius Jul 20 '23 at 18:14