<p>I want to print the internal IP of all nodes in the same line separated by a space using <code>jq</code> in k8s. How can I do this?</p>

<p>Using jsonpath I can filter using <code>.addresses[?(@.type=="InternalIP")]</code>. How to achieve the same with <code>jq</code>?</p>

<p>You could use select and pipe to achieve desired output.</p>

<p>below command shows the internal ip separated by new-line</p>

<pre><code>kubectl get nodes -o json | jq '.items[].status.addresses[] | select(.type=="InternalIP") | .address'
</code></pre>

<p>for space separated internal-ips:</p>

<pre><code>kubectl get nodes -o json | jq '.items[].status.addresses[] | select(.type=="InternalIP") | .address' | tr -d '\"' | tr '\n' ' '
</code></pre>
