<p>Here is a list of jobs that i´m running:</p>

<pre><code>&gt;kubectl get jobs 
NAME                 COMPLETIONS   DURATION   AGE
create-samplenames   1/1           32s        25h
download-db          1/1           20s        26h
download-fastq       1/1           20s        26h
download-scripts     1/1           22s        32m
trimming-fasta-1     0/1           63s        63s
trimming-fasta-2     0/1           63s        63s
trimming-fasta-3     0/1           63s        63s
trimming-fasta-4     0/1           62s        62s
</code></pre>

<p>I´m trying to wait until the trimming-fasta-* jobs are finished. I have found this post <a href="https://stackoverflow.com/questions/52862487/how-to-wait-until-kubernetes-list-of-pods-are-successful-using-shell-script">here</a> but it will return TRUE for some jobs that are finised. I really want to wait for all the trimming-fasta-* jobs are finisihed ??</p>

<pre><code>until kubectl  get jobs   -o jsonpath='{.items[*].status.conditions[?(@.type=="Complete")].status}' ; do sleep 1 ; done
True True True True(base) [david@archlinux otustaxonomy]$ 
</code></pre>

<p>Any idea to only check for trimming jobs. By the way they all belong to the same jobgrooup but havn´t found anything to check for jobgroup completion</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: trimming-fasta-$idx
  namespace: namespace-test
  labels:
    jobgroup: trimming
spec:....
</code></pre>

<p>Any idea ??</p>

david
<p>As per <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#wait" rel="nofollow noreferrer"><code>kubectl wait</code></a> usage:</p>

<blockquote>
  <p>$ <strong>wait</strong> ([-f FILENAME] | resource.group/<strong>resource.name</strong> | resource.group
  [(<strong>-l label</strong> | --all)]) [<strong>--for</strong>=delete|--for <strong>condition</strong>=available]</p>
</blockquote>

<p>You can use labels with <code>kubectl wait</code>, so just do the following to wait for all <em>trimming</em> jobs:</p>

<p><code>kubectl wait jobs -l jobgroup=trimming --for=condition=complete</code></p>
