I am trying to setup gitlab pipeline which builds and deploys to kubernetes. I am at step where i do
kubectl apply -f Application-k8s-file.yaml
and
kubectl rollout status deployment deployment_name
as you can see i am using rolling updates. Even though kubernetes deployment failed, i see status as waiting for pod. How do i make sure that my job fails when kubernetes deployment fails.
Check if you're setting the .spec.progressDeadlineSeconds
field. It denotes the number of seconds the Deployment controller waits before indicating that the Deployment progress has stalled.
This will cause the kubectl status rollout
command to fail after X amount of seconds.
kubectl rollout status deployment.v1.apps/nginx-deployment
Waiting for rollout to finish: 2 out of 3 new replicas have been updated...
error: deployment "nginx" exceeded its progress deadline
$ echo $?
1
More information: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#progress-deadline-seconds