<p>I'm trying to get the list of my Kubernetes cluster nodes based on some condition i.e. if Taint exists or not. I have 3 node cluster (1 master and 2 worker). I need to get the 2 worker node names as the taint is on master node. I'm stuck here as I'm getting the opposite result i.e. able to get the node with taint (master). Please assist to help me to put ! operator so that I can get only nodes without any taints.</p>
<p>This is my JSONPath query till now:-</p>
<pre><code>vagrant@mykubemaster:~$ kubectl get nodes
NAME           STATUS   ROLES                  AGE   VERSION
mykubemaster   Ready    control-plane,master   12d   v1.20.1
mykubenode01   Ready    &lt;none&gt;                 12d   v1.20.1
mykubenode02   Ready    &lt;none&gt;                 12d   v1.20.1
vagrant@mykubemaster:~$ kubectl get nodes -o=jsonpath='{$.items[?(@.spec.taints)].metadata.name}'
mykubemastervagrant@mykubemaster:~$
</code></pre>

vinod827
<p>Kubernetes/kubectl is using a <a href="https://github.com/kubernetes/client-go/blob/master/util/jsonpath/jsonpath.go" rel="nofollow noreferrer">Go JSONPath implementation</a> that (sadly) does not support path filter expressions with a negation; in fact, many implementations do not support syntax like:</p>
<pre><code>$[?(!(@.key==42))]
</code></pre>
<p>See this extensive <a href="https://cburgmer.github.io/json-path-comparison/" rel="nofollow noreferrer">comparisons</a>:</p>
<ul>
<li><a href="https://cburgmer.github.io/json-path-comparison/results/filter_expression_with_negation_and_equals.html" rel="nofollow noreferrer">Filter expression with negation and equals</a> &amp;</li>
<li><a href="https://cburgmer.github.io/json-path-comparison/results/filter_expression_with_negation_and_less_than.html" rel="nofollow noreferrer">Filter expression with negation and less</a></li>
</ul>
