Search code examples
kubernetesjqjsonpath

how to list the kubernetes pod which has CharDevice in it?


how to list the Kubernetes pod which has CharDevice in it ?

I could able to get the pod with CharDevice, but need to print the pod name only

kubectl get pod -o jsonpath='{spec.volumes.hostPath.type=="CharDevice"}'

Solution

  • You can get json first and use jq to get desired result :

    kubectl get pod -o json |
    jq -r '.items[]|select(any(.spec.volumes[];.hostPath.type=="CharDevice")).metadata.name'