<p>I want to write a kubectl command to query all the namespace and then collect the value of a specific lable.</p>
<pre><code>{
&quot;apiVersion&quot;: &quot;v1&quot;,
&quot;items&quot;: [
    {
        &quot;apiVersion&quot;: &quot;v1&quot;,
        &quot;kind&quot;: &quot;Namespace&quot;,
        &quot;metadata&quot;: {
            &quot;annotations&quot;: {
                &quot;kubectl.kubernetes.io/last-applied-configuration&quot;: &quot;{\&quot;apiVersion\&quot;:\&quot;v1\&quot;,\&quot;kind\&quot;:\&quot;Namespace\&quot;,\&quot;metadata\&quot;:{\&quot;annotations\&quot;:{},\&quot;labels\&quot;:{\&quot;app.kubernetes.io/created-by\&quot;:\&quot;testuser\&quot;,\&quot;app.kubernetes.io/instance\&quot;:\&quot;thisisatest\&quot;,\&quot;app.kubernetes.io/name\&quot;:\&quot;company\&quot;,\&quot;app.kubernetes.io/version\&quot;:\&quot;2.5\&quot;},\&quot;name\&quot;:\&quot;thisiatest\&quot;}}\n&quot;
            },
            &quot;creationTimestamp&quot;: &quot;2022-09-01T13:16:12Z&quot;,
            &quot;labels&quot;: {
                &quot;app.kubernetes.io/created-by&quot;: &quot;testuser&quot;,
                ...
</code></pre>
<p>I have a version with jq that works.</p>
<pre><code>printf &quot;\ncreated by:\n&quot;
kubectl get namespace -l app.kubernetes.io/name=phoenics -o json | jq '.items [] | .metadata | .labels | .&quot;app.kubernetes.io/created-by&quot;'
</code></pre>
<p>But i can't really get a version with jsonpath to work. What am i doing wrong?</p>
<pre><code>printf &quot;\ncreated by: JsonPath\n&quot;
kubectl get namespace -l app.kubernetes.io/name=phoenics -o jsonpath=&quot;{range ['items'][*]['metadata']['labels']['app.kubernetes.io/created-by']}{'\n'}{end}&quot;
</code></pre>
<p>There is no output. Oh, and i'm working on windows with a git bash.</p>

Patrick
<p>this should work:</p>
<pre class="lang-bash prettyprint-override"><code>kubectl get namespace -l app.kubernetes.io/name=phoenics \
-o jsonpath=&quot;{range .items[*]}{.metadata.labels.app\.kubernetes\.io/created-by}{'\n'}{end}&quot;
</code></pre>
