...
1 package status
2
3 import (
4 corev1 "k8s.io/api/core/v1"
5 )
6
7 const (
8 CrashLoopBackOff = "CrashLoopBackOff"
9 )
10
11
12
13
14 func IsPodReady(pod *corev1.Pod) bool {
15 if pod.Status.Phase != corev1.PodRunning {
16 return false
17 }
18 for _, con := range pod.Status.Conditions {
19 if con.Type == corev1.PodReady && con.Status == corev1.ConditionTrue {
20 return true
21 }
22 }
23 return false
24 }
25
26
27
28 func IsContainerCLBO(status corev1.ContainerStatus, threshold uint16) bool {
29 if status.Ready {
30 return false
31 }
32 if status.State.Waiting == nil || status.State.Waiting.Reason != CrashLoopBackOff {
33 return false
34 }
35 return status.RestartCount > int32(threshold)
36 }
37
View as plain text