<p>I would like to filter my <code>kubectl get deploy</code> command based on the value of an annotation.</p>
<p>Something similar to <code>kubectl get deploy --annotation stork.libopenstorage.org/skipresource!=&quot;true&quot;</code></p>
<p>Currently no clue how to do this and we don't want to add an extra label. Output of both commands above should be something like below:</p>
<pre><code>kubectl get deploy 
NAME                        READY   UP-TO-DATE   AVAILABLE   AGE
elastalert                  1/1     1            1           33d
es-hq                       1/1     1            1           33d
etcdsnapshots               1/1     1            1           33d
fluentd-aggregator          2/2     2            2           33d
kibana                      1/1     1            1           33d

kubectl get deploy --annotation stork.libopenstorage.org/skipresource!=&quot;true&quot;
NAME                        READY   UP-TO-DATE   AVAILABLE   AGE
etcdsnapshots               1/1     1            1           33d
fluentd-aggregator          2/2     2            2           33d
kibana                      1/1     1            1           33d

kubectl get deploy --annotation stork.libopenstorage.org/skipresource=&quot;true&quot;
NAME                        READY   UP-TO-DATE   AVAILABLE   AGE
elastalert                  1/1     1            1           33d
es-hq                       1/1     1            1           33d
</code></pre>

Jeromba6
<p>I have a deployment with the annotation prometheus.io/scrape="true"</p>

<p>I can get the deployments having that annotation by</p>

<pre><code>kubectl get deploy -o=jsonpath='{.items[?(@.spec.template.metadata.annotations.prometheus\.io/scrape=="true")].metadata.name}'
</code></pre>

<p>The above uses the Jsonpath concept and the docs can be found at <a href="https://kubernetes.io/docs/reference/kubectl/jsonpath/" rel="noreferrer">here</a></p>

<p>In your case the command might be like</p>

<pre><code>kubectl get deploy -o=jsonpath='{.items[?(@.spec.template.metadata.annotations.stork\.libopenstorage\.org/skipresource=="true")].metadata.name}'
</code></pre>

<p>This concept can be applied to other kubernetes resources as well.One other command that might help in understanding the earlier commands is </p>

<pre><code> kubectl get deployment -o=json
</code></pre>
