<p>I am trying to get pvc and it's volume and in which pod it is mounted and the node it is hosted.</p>

<p>There are separate commands are there like below</p>

<p>To get PVC and it's volume</p>

<pre><code>kubectl get pvc &lt;pvcname&gt;
</code></pre>

<p>then from PVC i am getting where it is mounted </p>

<pre><code>kubectl describe pvc &lt;pvcname&gt; | grep Mounted
</code></pre>

<p>Then getting the pod , i am find in which node the pod is hosted</p>

<pre><code> kubectl get pod &lt;pod name&gt; -o wide
</code></pre>

<p>As often i need to check this and having lot of PVC created by PVC config ,running one by one is complex task. May be a script can be written. Is there any other way using kubectl filter i can get these in single command?</p>

<p>Currently i am doing like this and finding node names where the pvc is mounted.</p>

<pre><code>pvc_list=$(kubectl get pvc | awk '{print $1}')
pod_list=$(kubectl describe pvc $pvc_list | grep Mounted | awk '{print $NF}')
kubectl get pod $pod_list -o wide
</code></pre>

<p>But I need to get like this </p>

<pre><code>PVC_name volume Pod_Name Node_Name
PvcTest   voltest  pod1   node1 
</code></pre>

Samselvaprabu
<p>A PVC can be used on any number of pods so this model does not match how Kubernetes works. You could of course write your own script that ignores that possibility.</p>
