Show k8s pod status

This commit is contained in:
Tom Wilkie
2016-04-13 11:56:26 +01:00
parent 4ce6c13c89
commit 3fcd74f8d1
2 changed files with 9 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ const (
PodName = "kubernetes_pod_name"
PodCreated = "kubernetes_pod_created"
PodContainerIDs = "kubernetes_pod_container_ids"
PodState = "kubernetes_pod_state"
ServiceIDs = "kubernetes_service_ids"
)
@@ -73,6 +74,10 @@ func (p *pod) AddServiceID(id string) {
p.serviceIDs = append(p.serviceIDs, id)
}
func (p *pod) State() string {
return string(p.Status.Phase)
}
func (p *pod) GetNode() report.Node {
n := report.MakeNodeWith(map[string]string{
PodID: p.ID(),
@@ -80,6 +85,7 @@ func (p *pod) GetNode() report.Node {
Namespace: p.Namespace(),
PodCreated: p.Created(),
PodContainerIDs: strings.Join(p.ContainerIDs(), " "),
PodState: p.State(),
})
if len(p.serviceIDs) > 0 {
n = n.WithLatests(map[string]string{ServiceIDs: strings.Join(p.serviceIDs, " ")})

View File

@@ -11,8 +11,9 @@ import (
var (
PodMetadataTemplates = report.MetadataTemplates{
PodID: {ID: PodID, Label: "ID", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
PodCreated: {ID: PodCreated, Label: "Created", From: report.FromLatest, Priority: 3},
PodState: {ID: PodState, Label: "State", From: report.FromLatest, Priority: 2},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 3},
PodCreated: {ID: PodCreated, Label: "Created", From: report.FromLatest, Priority: 4},
}
ServiceMetadataTemplates = report.MetadataTemplates{