+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.
How to find "what pods are using particular PVC through command line"
+1 for the feature.
@azzaka 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
@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.
Workaround for the meantime:
'.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName:.spec.volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'```
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 }'
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 :)
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.
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.
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.
$ 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.