Display node type on k8s controller nodes

Since there are multiple types in the same topology, displaying the type is important.
We do this in multiple places:

* Add node type to minor label

* Add node type as metadata and include in metadata template.
  Even though this will always be the same for every node of that topology, this was
  the easiest way to add it so it displays in the table view.
  Note we can't control ordering of columns in table view, it's always alphabetical.
This commit is contained in:
Mike Lang
2017-06-27 10:19:04 -07:00
parent 4f341cb1d2
commit 889972c48a
4 changed files with 17 additions and 1 deletions
+1
View File
@@ -48,5 +48,6 @@ func (d *daemonSet) GetNode() report.Node {
DesiredReplicas: fmt.Sprint(d.Status.DesiredNumberScheduled),
Replicas: fmt.Sprint(d.Status.CurrentNumberScheduled),
MisscheduledReplicas: fmt.Sprint(d.Status.NumberMisscheduled),
NodeType: "Daemon Set",
})
}
+1
View File
@@ -54,5 +54,6 @@ func (d *deployment) GetNode(probeID string) report.Node {
UnavailableReplicas: fmt.Sprint(d.Status.UnavailableReplicas),
Strategy: string(d.Spec.Strategy.Type),
report.ControlProbeID: probeID,
NodeType: "Deployment",
}).WithLatestActiveControls(ScaleUp, ScaleDown)
}
+3
View File
@@ -21,6 +21,7 @@ const (
ObservedGeneration = "kubernetes_observed_generation"
Replicas = "kubernetes_replicas"
DesiredReplicas = "kubernetes_desired_replicas"
NodeType = "kubernetes_node_type"
)
// Exposed for testing
@@ -46,6 +47,7 @@ var (
ServiceMetricTemplates = PodMetricTemplates
DeploymentMetadataTemplates = report.MetadataTemplates{
NodeType: {ID: NodeType, Label: "Type", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: "datetime", Priority: 3},
ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Datatype: "number", Priority: 4},
@@ -67,6 +69,7 @@ var (
ReplicaSetMetricTemplates = PodMetricTemplates
DaemonSetMetadataTemplates = report.MetadataTemplates{
NodeType: {ID: NodeType, Label: "Type", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: "datetime", Priority: 3},
DesiredReplicas: {ID: DesiredReplicas, Label: "Desired Replicas", From: report.FromLatest, Datatype: "number", Priority: 4},
+12 -1
View File
@@ -257,13 +257,24 @@ func podNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
return base, true
}
var podGroupNodeTypeName = map[string]string{
report.Deployment: "Deployment",
report.DaemonSet: "Daemon Set",
report.ReplicaSet: "Replica Set",
}
func podGroupNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
base = addKubernetesLabelAndRank(base, n)
base.Stack = true
// NB: pods are the highest aggregation level for which we display
// counts.
base.LabelMinor = pluralize(n.Counters, report.Pod, "pod", "pods")
count := pluralize(n.Counters, report.Pod, "pod", "pods")
if typeName, ok := podGroupNodeTypeName[n.Topology]; ok {
base.LabelMinor = fmt.Sprintf("%s of %s", typeName, count)
} else {
base.LabelMinor = count
}
return base, true
}