use pod phase/status (#1356)
This commit is contained in:
parent
5712aafba9
commit
03031a694d
@ -117,19 +117,22 @@ func (k *kubernetes) getService(labels map[string]string) ([]*service, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the status from the pods
|
// get the status from the pods
|
||||||
status := "unknown"
|
var status string
|
||||||
if len(podList.Items) > 0 {
|
|
||||||
switch podList.Items[0].Status.Conditions[0].Type {
|
for _, item := range podList.Items {
|
||||||
case "PodScheduled":
|
switch item.Status.Phase {
|
||||||
status = "starting"
|
case "Failed":
|
||||||
case "Initialized":
|
status = item.Status.Reason
|
||||||
status = "starting"
|
default:
|
||||||
case "Ready":
|
status = item.Status.Phase
|
||||||
status = "ready"
|
|
||||||
case "ContainersReady":
|
|
||||||
status = "ready"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unknown status
|
||||||
|
if len(status) == 0 {
|
||||||
|
status = "n/a"
|
||||||
|
}
|
||||||
|
|
||||||
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
|
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
|
||||||
logger.Debugf("Runtime setting %s service deployment status: %v", name, status)
|
logger.Debugf("Runtime setting %s service deployment status: %v", name, status)
|
||||||
}
|
}
|
||||||
|
@ -103,9 +103,10 @@ type Pod struct {
|
|||||||
|
|
||||||
// PodStatus
|
// PodStatus
|
||||||
type PodStatus struct {
|
type PodStatus struct {
|
||||||
|
Conditions []PodCondition `json:"conditions,omitempty"`
|
||||||
PodIP string `json:"podIP"`
|
PodIP string `json:"podIP"`
|
||||||
Phase string `json:"phase"`
|
Phase string `json:"phase"`
|
||||||
Conditions []PodCondition `json:"conditions,omitempty"`
|
Reason string `json:"reason"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodCondition describes the state of pod
|
// PodCondition describes the state of pod
|
||||||
|
Loading…
Reference in New Issue
Block a user