Before this change I got "unknown" status for some pods:
# ./check_kube_deployments.sh -n kube-system
Unknown: coredns has condition Progressing
Available: True
True - ReplicaSet "coredns-74ff55c5b" has successfully progressed.
Deployment has minimum availability.
# echo $?
3
This is because there are two "historical" conditions - one emitted at "13:22:06" saying "Progressing" and then a newer one at "17:57:55" saying "Available". However, "check_kube_deployments.sh" took the older one:
After this change, the conditions are sorted from oldest to newest and code takes only the last (newest) status:
# ./check_kube_deployments.sh -n kube-system
OK - Kubernetes deployments are all OK
OK: coredns has condition Available: True - Deployment has minimum availability.
# echo $?
0
Before this change I got "unknown" status for some pods:
This is because there are two "historical" conditions - one emitted at "13:22:06" saying "Progressing" and then a newer one at "17:57:55" saying "Available". However, "check_kube_deployments.sh" took the older one:
After this change, the conditions are sorted from oldest to newest and code takes only the last (newest) status: