<p>Is there a way to watch the job's output (STDOUT and STDERR) using kubectl? We need to wait the job completion watching its output and, if the job finishes with error, the entire process should be interrupted. </p>

<p>I'd like to redirect the job output (STDOUT and STDERR) to my current process STDOUT. I want to wait the job completion. In case it finished with error, the current process (which triggered the job via kubectl) should finish in error as well. I know <code>kubectl wait</code> but, as far as I know, it does not support listening to the jobs output.  </p>

viniciusjssouza
<p>We ended up using three commands to accomplish the task. First, we delete the old job (it might have ran before), create the new job, wait it for completion (with a timeout) and, after it has finished, we print the logs:</p>
<pre><code>kubectl delete job my-job || true
kubectl apply -f ./jobs/my-job.yaml
kubectl wait --for=condition=complete job/my-job --timeout=60s
echo &quot;Job output:&quot;
kubectl logs job/my-job
</code></pre>
