Code change:
return "", err } <ins> pc := d.Core().Pods(namespace) mountPods, err := getMountPods(pc, pvc.Name) if err != nil { return "", err } </ins> events, _ := d.Core().Events(namespace).Search(legacyscheme.Scheme, pvc) <del> return describePersistentVolumeClaim(pvc, events) </del> <ins> return describePersistentVolumeClaim(pvc, events, mountPods) } func getMountPods(c coreclient.PodInterface, pvcName string) ([]api.Pod, error) { nsPods, err := c.List(metav1.ListOptions{}) if err != nil { return []api.Pod{}, err } var pods []api.Pod for _, pod := range nsPods.Items { pvcs := getPvcs(pod.Spec.Volumes) for _, pvc := range pvcs { if pvc.PersistentVolumeClaim.ClaimName == pvcName { pods = append(pods, pod) } } } return pods, nil </ins> } <del> func describePersistentVolumeClaim(pvc *api.PersistentVolumeClaim, events *api.EventList) (string, error) { </del> <ins> func getPvcs(volumes []api.Volume) []api.Volume { var pvcs []api.Volume for _, volume := range volumes { if volume.VolumeSource.PersistentVolumeClaim != nil { pvcs = append(pvcs, volume) } } return pvcs } func describePersistentVolumeClaim(pvc *api.PersistentVolumeClaim, events *api.EventList, mountPods []api.Pod) (string, error) { </ins> return tabbedString(func(out io.Writer) error { w := NewPrefixWriter(out) w.Write(LEVEL_0, "Name:t%sn", pvc.Name)

Related discussion:
text: Is this a BUG REPORT or FEATURE REQUEST?: /kind feature What happened: I need to know to which Pod(s) a PVC is being mounted to, without having to go through each Pod one by one checking the Volume mounts and the PersistentVolumeClaim. The kubectl describe pvc and get pvc, only tell you to which Persistent Volume the PVC is bound to, but not if is being used by a Pod(s) What you expected to happen: Add a new field in the describe or get that lists the pods that are using the PVC as a volume mount How to reproduce it (as minimally and precisely as possible): Have a PV/PVC bound and create a pod using a volume mount Anything else we need to know?: Not sure if this is only for Azure Disk, which is the Storage Class I am using. Environment: Kubernetes version (use ): 7 Cloud provider or hardware configuration: Azure OS (e.g. from /etc/os-release): Ubuntu 16.04 Kernel (e.g. ): 4 Install tools: Azure Kubernetes Services Others: -n/a
/sig storage
/sig cli
I think the kubectl describe can just construct this on the fly. Another angle is should we add this information to PVC object itself
That will be great, as right now the only way to correlate a PVC to a Pod is via a "describe" on the Pod.
I can work on a PR for this!
GitHub didn't allow me to assign the following users: clandry94. Note that only and repo collaborators can be assigned. <detailsIn response to : I can work on this! Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
+1 for the feature. cc
How to find "what pods are using particular PVC through command line"
+1 for the feature.
this feature will be in Kubernetes 1.12
ok kubernetes 1.12 released, how to? which command?
Can someone point to the documentation or paste command to get the pods which have the PVC in use
see the associated PR to see an example usage of this The line in should show it.
Workaround for the meantime:
Thanks , this workaround is great for those people who still use old kubernetes version.