<p>I have deployed a Kubernetes service and when I query to get the Deployment <code>$ kubectl get deployments</code>, I can see the Deployment. 
the <code>json</code> of the Deployment looks like below -- </p>

<pre><code>apiVersion: v1
kind: Deployment
metadata:
 name: test
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: test
        release: testRelease
        customProp: xyz
</code></pre>

<p>My question is how can I frame a query by which I can get the Deployment by specifying the <strong>'customProp'</strong> value. Does <code>kubectl</code> support to pass a jsonpath as part of the query? so that I can pass a <code>json</code> path like <code>jsonpath='{$.spec.template.metadata.labels.customProp}'</code> and value against this jsonPath as <strong>'xyz'</strong>. </p>

<p>This is what I am thinking to execute:</p>

<pre><code>$ kubectl get deployments -n &lt;namespace&gt; &lt;json path query&gt;
</code></pre>

<p>However not sure how to frame the <code>json</code> path query and pass along with <code>$kubectl get deployments</code>.</p>

Gautam Moulik
<p>Kubectl does support <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/" rel="nofollow noreferrer">query feature</a>, you can use below query</p>

<pre><code>kubectl get pods --selector=customProp=xyz
</code></pre>

<p>Kubectl also supports JSON path expressions too, to get more details, follow the <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources" rel="nofollow noreferrer">link</a>. You can write query following the syntax shown on the link.</p>
