title: How to filter finished jobs in kubernetes
body: <p>I'm trying to filter jobs that are complete using golang kubernetes client-go lib by their status.</p>
  
  <p>I've checked <a href="https://stackoverflow.com/a/53412583/268673">other answers</a> explaining how to get the jobs using kubectl, like this:</p>
  
  <pre><code>kubectl get job -o=jsonpath='{.items[?(@.status.succeeded==1)].metadata.name}'
  </code></pre>
  
  <p>But I don't know how to "turn" that jsonpath output into a filter or list options</p>
  
  <p>If I were searching for pods by their status phase and a label I would do something like this:</p>
  
  <pre class="lang-golang prettyprint-override"><code>listOptions := metav1.ListOptions{
      LabelSelector: "app.kubernetes.io/name=my-custom-job",
      FieldSelector: "status.phase=Running",
  }
  result, err := clientset.CoreV1().Pods("default").List(listOptions) 
  </code></pre>
  
  <p>But if I am going to implement the jsonpath <code>{.items[?(@.status.succeeded==1)].metadata.name}</code></p>
  
  <p>This is going to iterate through all jobs and check if the succeeded key under status is equal to one. For all jobs.</p>
  
  <p><strong>Is there a way to look for those jobs more "memory friendly" or a way to use jsonpaths like that in ListOptions?</strong></p>