kubernetes 查看哪些 pod 正在使用 pvc
通过查看json格式的pod信息,并通过jq去处理获取到想要的字段
[root@devma01 test-storageclass]# kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName:.spec.volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'
{"name":"eucp-dev-es7211-deployment-7cd989b4b6-rbn95","namespace":"dev","claimName":"futui-dev-single-es"}
{"name":"mrp-web-service-774cc4d579-fn2f7","namespace":"dev","claimName":"dev-pvc"}
{"name":"futui-test-pika-fh9xq","namespace":"futui-test","claimName":"futui-test-pvc"}
现在学习还不晚;