<p>I want given a Job name find name of created Pod by Job controller using the OpenShift or Kubernetes REST API.</p>

<p>Using the CLI, this is possible by doing:</p>

<pre><code>$ oc describe job testapi | grep -A 4 Events
Events:
  Type    Reason            Age   From            Message
  ----    ------            ----  ----            -------
  Normal  SuccessfulCreate  6m    job-controller  Created pod: testapi-gff8c
</code></pre>

<p>Can we do same operation using the REST API?</p>

<p>I would like to get Pod names to get logs of all pods generated by a Job.</p>

scoulomb
<p>The describe command is aggregating multiple results to provide its output so you will need to do a bit of extra work.</p>

<p>Call the <code>events</code> endpoint and parse the results using a tool like jq or can be pulled out in part by grep.</p>

<p>Heres an example assuming the job name is <code>testapi</code> and the namespace is <code>myproject</code>:</p>

<p><code>curl -H "Authorization: Bearer $(oc whoami -t)" -k https://127.0.0.1:8443/api/v1/namespaces/myproject/events?fieldSelector=involvedObject.name%3Dtestapi%2CinvolvedObject.namespace%3Dmyproject%2CinvolvedObject.kind%3DJob | grep Created</code></p>
