Re: [kubernetes/kubernetes] Display which Pods have the PVC in use. (#65233)

7 views
Skip to first unread message

Pengfei Ni

unread,
Jul 2, 2018, 10:22:05 PM7/2/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

+1 for the feature.

cc @kubernetes/sig-cli-feature-requests


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Kubernetes Submit Queue

unread,
Jul 6, 2018, 2:04:30 PM7/6/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Closed #65233 via #65837.

Pradeep Kumar Kaloori

unread,
Aug 7, 2018, 2:07:44 PM8/7/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

How to find "what pods are using particular PVC through command line"

Lee Goile

unread,
Aug 17, 2018, 9:29:10 AM8/17/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

+1 for the feature.

Conor Landry

unread,
Aug 17, 2018, 10:10:20 AM8/17/18
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@azzaka this feature will be in Kubernetes 1.12

porrascarlos802018

unread,
Feb 27, 2019, 10:35:07 AM2/27/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

ok kubernetes 1.12 released, how to? which command?

Aman Jain

unread,
Mar 27, 2019, 4:43:05 AM3/27/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Can someone point to the documentation or paste command to get the pods which have the PVC in use

Conor Landry

unread,
Mar 27, 2019, 10:59:05 AM3/27/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

@porrascarlos802018 @amanjain08 see the associated PR to see an example usage of this #65837. The Mounted By line in kubectl describe pvc should show it.

Moshe Avni

unread,
Jun 18, 2019, 3:00:48 AM6/18/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Workaround for the meantime:

'.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName:.spec.volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'```

silenceshell

unread,
Jul 16, 2019, 11:46:33 PM7/16/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Thanks @Moshem123 , this workaround is great for those people who still use old kubernetes version.

However it will meet an error if the pod have no volumes, so I improves it by adding a has to check whether the volumes exists or not.

kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName: .spec |  select( has ("volumes") ).volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'

Nicolas Kowenski

unread,
Sep 5, 2019, 11:50:33 AM9/5/19
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

python script to list pods with pvc in namespace(s):
https://gist.github.com/zakkg3/8c4f6b5e015d1229bf0643156b30ecdc
Is a part of a cli to set pods with velero/restic annotations.
Hope it helps someone :)

MrWetsnow

unread,
Jul 19, 2021, 12:12:27 PM7/19/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

For posterity... There is a *Used By: * field in the output of describe.

% k describe -n staging pvc grafana-hi9f 
Name:          grafana-hi9f
Namespace:     staging
StorageClass:  standard
Status:        Bound
Volume:        pvc-041c1e08-bee7-4b2d-bbc1-5dda4496d09d
Labels:        app.kubernetes.io/instance=grafana-hi9f
               app.kubernetes.io/managed-by=Helm
               app.kubernetes.io/name=grafana
               app.kubernetes.io/version=8.0.5
               helm.sh/chart=grafana-6.13.10
Annotations:   pv.kubernetes.io/bind-completed: yes
               pv.kubernetes.io/bound-by-controller: yes
               volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/gce-pd
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      10Gi
Access Modes:  RWO
VolumeMode:    Filesystem
Used By:       grafana-hi9f-5f7d8b94d5-6tvsm
Events:        <none>


You are receiving this because you are on a team that was mentioned.

Reply to this email directly, view it on GitHub, or unsubscribe.

lajiao117

unread,
Aug 23, 2021, 7:00:35 AM8/23/21
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

client-go didn't give this api...


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications on the go with GitHub Mobile for iOS or Android.

Muhammed Hussein karimi

unread,
Feb 1, 2022, 5:55:03 AM2/1/22
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

Thanks @Moshem123 , this workaround is great for those people who still use old kubernetes version.

However it will meet an error if the pod have no volumes, so I improves it by adding a has to check whether the volumes exists or not.

kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName: .spec |  select( has ("volumes") ).volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'

Hi thanks worked for me ;)
but I want to make it reverse my workarounds with adding not after has didn't worked
do you have any ideas

kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName: .spec | select( has ( "volumes" ) ).volumes[] | select( has ( "persistentVolumeClaim" ) | not ).persistentVolumeClaim.claimName}'


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are on a team that was mentioned.Message ID: <kubernetes/kubernetes/issues/65233/1026713698@github.com>

jeromeza

unread,
Sep 21, 2022, 7:15:38 AM9/21/22
to kubernetes/kubernetes, k8s-mirror-cli-feature-requests, Team mention

$ kubectl describe pvc -A | grep -E "Name|StorageClass|Used"

Name: ocs-deviceset-lso-volumeset-0-data-1b45dn
Namespace: openshift-storage
StorageClass: lso-volumeset
Used By: rook-ceph-osd-1-6c8c74dcd5-8fwpd

Also useful ^


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are on a team that was mentioned.Message ID: <kubernetes/kubernetes/issues/65233/1253556934@github.com>

Reply all
Reply to author
Forward
Message has been deleted
0 new messages