I'm setting up a CI/CD pipeline. The deployment step runs these commands:
kubectl apply -f manifest.yml --namespace <namespace>
kubectl rollout status Deployment/<service> --namespace <namespace>
This gives the following output:
Waiting for deployment "<service>" rollout to finish: 1 out of 2 new replicas have been updated...
error: deployment "<service>" exceeded its progress deadline
##[error]error: deployment "<service>" exceeded its progress deadline
By running
kubectl get pods
I can see it has started a pod which is stuck in CrashLoopBackOff. I can see why the pod failed to start by running:
kubectl logs <pod-name>
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.)
If it's not already the case, labelize you pod :
apiVersion: v1
kind: Pod
metadata:
name: label-demo
labels:
environment: production
app: nginx
It enables you to see the logs without the pod name :
kubectl logs -l app=nginx -n your-namespace
For the CrashLoopBackOff
error, events give often more information than the logs :
kubectl get events --sort-by lastTimestamp -n your-namespace
Add this at this end of your pipeline, it will give you interesting information about your pod scheduling, ect...