<p>I'm setting up a CI/CD pipeline. The deployment step runs these commands:</p>

<pre><code>kubectl apply -f manifest.yml --namespace &lt;namespace&gt;
kubectl rollout status Deployment/&lt;service&gt; --namespace &lt;namespace&gt;
</code></pre>

<p>This gives the following output:</p>

<pre><code>Waiting for deployment "&lt;service&gt;" rollout to finish: 1 out of 2 new replicas have been updated...
error: deployment "&lt;service&gt;" exceeded its progress deadline
##[error]error: deployment "&lt;service&gt;" exceeded its progress deadline
</code></pre>

<p>By running </p>

<pre><code>kubectl get pods
</code></pre>

<p>I can see it has started a pod which is stuck in CrashLoopBackOff. I can see why the pod failed to start by running:</p>

<pre><code>kubectl logs &lt;pod-name&gt;
</code></pre>

<p>Is there a way to include this output in the deployment log? I can obviously check if the deployment failed, then parse the above commands and display the log output, but I would hope there's some way to get this information out of kubectl rollout status (preferably if there were a way to make kubectl rollout status notify whenever a pod in the deployment had a status change, and show logs for any pods with an error status change.)</p>

Luke Schlather
<p>If it's not already the case, <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/" rel="nofollow noreferrer">labelize</a> you pod :</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: label-demo
  labels:
    environment: production
    app: nginx
</code></pre>

<p>It enables you to see the logs without the pod name :</p>

<pre><code>kubectl logs -l app=nginx -n your-namespace
</code></pre>

<p>For the <code>CrashLoopBackOff</code> error, events give often more information than the logs :</p>

<pre><code>kubectl get events --sort-by lastTimestamp -n your-namespace
</code></pre>

<p>Add this at this end of your pipeline, it will give you interesting information about your pod scheduling, ect...</p>
