mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Add Kubernetes service type and ports
This commit is contained in:
@@ -23,6 +23,8 @@ const (
|
||||
Replicas = report.KubernetesReplicas
|
||||
DesiredReplicas = report.KubernetesDesiredReplicas
|
||||
NodeType = report.KubernetesNodeType
|
||||
Type = report.KubernetesType
|
||||
Ports = report.KubernetesPorts
|
||||
)
|
||||
|
||||
// Exposed for testing
|
||||
@@ -44,6 +46,8 @@ var (
|
||||
PublicIP: {ID: PublicIP, Label: "Public IP", From: report.FromLatest, Datatype: report.IP, Priority: 4},
|
||||
IP: {ID: IP, Label: "Internal IP", From: report.FromLatest, Datatype: report.IP, Priority: 5},
|
||||
report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: report.Number, Priority: 6},
|
||||
Type: {ID: Type, Label: "Type", From: report.FromLatest, Priority: 7},
|
||||
Ports: {ID: Ports, Label: "Ports", From: report.FromLatest, Priority: 8},
|
||||
}
|
||||
|
||||
ServiceMetricTemplates = PodMetricTemplates
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/weaveworks/scope/report"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
@@ -37,11 +39,29 @@ func (s *service) Selector() labels.Selector {
|
||||
return labels.SelectorFromSet(labels.Set(s.Spec.Selector))
|
||||
}
|
||||
|
||||
// human-readable version of a Kubernetes ServicePort
|
||||
func servicePortString(p apiv1.ServicePort) string {
|
||||
if p.NodePort == 0 {
|
||||
return fmt.Sprintf("%d/%s", p.Port, p.Protocol)
|
||||
}
|
||||
return fmt.Sprintf("%d:%d/%s", p.Port, p.NodePort, p.Protocol)
|
||||
}
|
||||
|
||||
func (s *service) GetNode() report.Node {
|
||||
latest := map[string]string{IP: s.Spec.ClusterIP}
|
||||
latest := map[string]string{
|
||||
IP: s.Spec.ClusterIP,
|
||||
Type: string(s.Spec.Type),
|
||||
}
|
||||
if s.Spec.LoadBalancerIP != "" {
|
||||
latest[PublicIP] = s.Spec.LoadBalancerIP
|
||||
}
|
||||
if len(s.Spec.Ports) != 0 {
|
||||
portStr := ""
|
||||
for _, p := range s.Spec.Ports {
|
||||
portStr = portStr + servicePortString(p) + ","
|
||||
}
|
||||
latest[Ports] = portStr[:len(portStr)-1]
|
||||
}
|
||||
return s.MetaNode(report.MakeServiceNodeID(s.UID())).WithLatests(latest)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ const (
|
||||
KubernetesLastScheduled = "kubernetes_last_scheduled"
|
||||
KubernetesActiveJobs = "kubernetes_active_jobs"
|
||||
KubernetesStateDeleted = "deleted"
|
||||
KubernetesType = "kubernetes_type"
|
||||
KubernetesPorts = "kubernetes_ports"
|
||||
// probe/awsecs
|
||||
ECSCluster = "ecs_cluster"
|
||||
ECSCreatedAt = "ecs_created_at"
|
||||
@@ -173,6 +175,8 @@ var commonKeys = map[string]string{
|
||||
KubernetesSuspended: KubernetesSuspended,
|
||||
KubernetesLastScheduled: KubernetesLastScheduled,
|
||||
KubernetesActiveJobs: KubernetesActiveJobs,
|
||||
KubernetesType: KubernetesType,
|
||||
KubernetesPorts: KubernetesPorts,
|
||||
|
||||
ECSCluster: ECSCluster,
|
||||
ECSCreatedAt: ECSCreatedAt,
|
||||
|
||||
Reference in New Issue
Block a user