<p>Is there a simple method (that won't require googling at every use) to get names of all deployment configs with no running pods (scaled to 0) in Kubernetes / Openshift? Methods without JSON tokens and <code>awk</code> please. </p>

<p>The docs of <code>oc get dc --help</code> are way too long to decipher for the occasional need.</p>

mirekphd
<p>The only CLI arg for advanced filtering without working with JSON is a <code>--field-selector</code>, but it has a <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/v1/conversion.go#L33" rel="nofollow noreferrer">limited scope</a> which not include <code>spec.replicas</code> field.</p>

<p>So, there will be some magic around JSON with other flag - <code>jsonpath</code>.</p>

<p>Here is a command to filter and print names of all deployments which are scaled to 0:</p>

<pre><code>kubectl get deployments --all-namespaces -o=jsonpath='{range .items[?(@.spec.replicas==0)]}{.metadata.name}{"\n"}{end}'
</code></pre>

<p><code>Jsonpath</code> reference is <a href="https://kubernetes.io/docs/reference/kubectl/jsonpath/" rel="nofollow noreferrer">here</a>. </p>
