Skip to content

Commit

Permalink
Merge pull request #1378 from weaveworks/1343-k8s-external-ip
Browse files Browse the repository at this point in the history
Show the k8s load balancer IP if it is set
  • Loading branch information
paulbellamy committed Apr 26, 2016
2 parents 6c491c7 + d559a6c commit 9adbfa9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
9 changes: 5 additions & 4 deletions probe/kubernetes/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ var (
}

ServiceMetadataTemplates = report.MetadataTemplates{
ServiceID: {ID: ServiceID, Label: "ID", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
ServiceCreated: {ID: ServiceCreated, Label: "Created", From: report.FromLatest, Priority: 3},
ServiceIP: {ID: ServiceIP, Label: "Internal IP", From: report.FromLatest, Priority: 4},
ServiceID: {ID: ServiceID, Label: "ID", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
ServiceCreated: {ID: ServiceCreated, Label: "Created", From: report.FromLatest, Priority: 3},
ServicePublicIP: {ID: ServicePublicIP, Label: "Public IP", From: report.FromLatest, Priority: 4},
ServiceIP: {ID: ServiceIP, Label: "Internal IP", From: report.FromLatest, Priority: 5},
}

PodTableTemplates = report.TableTemplates{
Expand Down
5 changes: 3 additions & 2 deletions probe/kubernetes/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ var (
CreationTimestamp: unversioned.Now(),
},
Spec: api.ServiceSpec{
Type: api.ServiceTypeLoadBalancer,
ClusterIP: "10.0.1.1",
Type: api.ServiceTypeLoadBalancer,
ClusterIP: "10.0.1.1",
LoadBalancerIP: "10.0.1.2",
Ports: []api.ServicePort{
{Protocol: "TCP", Port: 6379},
},
Expand Down
9 changes: 7 additions & 2 deletions probe/kubernetes/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
ServiceName = "kubernetes_service_name"
ServiceCreated = "kubernetes_service_created"
ServiceIP = "kubernetes_service_ip"
ServicePublicIP = "kubernetes_service_public_ip"
ServiceLabelPrefix = "kubernetes_service_label_"
)

Expand Down Expand Up @@ -55,11 +56,15 @@ func (s *service) Selector() labels.Selector {
}

func (s *service) GetNode() report.Node {
return report.MakeNodeWith(report.MakeServiceNodeID(s.Namespace(), s.Name()), map[string]string{
latest := map[string]string{
ServiceID: s.ID(),
ServiceName: s.Name(),
ServiceCreated: s.ObjectMeta.CreationTimestamp.Format(time.RFC822),
Namespace: s.Namespace(),
ServiceIP: s.Spec.ClusterIP,
}).AddTable(ServiceLabelPrefix, s.Labels)
}
if s.Spec.LoadBalancerIP != "" {
latest[ServicePublicIP] = s.Spec.LoadBalancerIP
}
return report.MakeNodeWith(report.MakeServiceNodeID(s.Namespace(), s.Name()), latest).AddTable(ServiceLabelPrefix, s.Labels)
}

0 comments on commit 9adbfa9

Please sign in to comment.