Skip to content

Commit

Permalink
feat: link kubernetes LB services to AWS ELB
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Jul 9, 2024
1 parent 789ba21 commit 9090d06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scrapers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ func (aws Scraper) loadBalancers(ctx *AWSContext, config v1.AWS, results *v1.Scr
Name: *lb.LoadBalancerName,
Labels: labels,
Tags: tags,
Aliases: []string{"AWSELB/" + arn, arn},
Aliases: []string{"AWSELB/" + arn, arn, lo.FromPtr(lb.CanonicalHostedZoneName)},
ID: *lb.LoadBalancerName,
Parents: []v1.ConfigExternalKey{{Type: v1.AWSEC2VPC, ExternalID: lo.FromPtr(lb.VPCId)}},
RelationshipResults: relationships,
Expand Down
7 changes: 7 additions & 0 deletions scrapers/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,13 @@ func ExtractResults(ctx api.ScrapeContext, config v1.Kubernetes, objs []*unstruc
if ingress, ok := ing.(map[string]any); ok {
if hostname, ok := ingress["hostname"].(string); ok && hostname != "" {
labels["hostname"] = hostname

if strings.HasSuffix(hostname, "elb.amazonaws.com") {
relationships = append(relationships, v1.RelationshipResult{
ConfigID: string(obj.GetUID()),
RelatedExternalID: v1.ExternalID{ExternalID: []string{hostname}, ConfigType: v1.AWSLoadBalancer},
})
}
}

if ip, ok := ingress["ip"].(string); ok && ip != "" {
Expand Down

0 comments on commit 9090d06

Please sign in to comment.