Skip to content

Commit

Permalink
feat: link eks cluster node to aws::eks cluster
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
adityathebe committed Jan 8, 2024
1 parent 7862b99 commit 3187624
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions scrapers/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ func (kubernetes KubernetesScraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResul
}
}

if obj.GetKind() == "Node" {
if clusterName, ok := obj.GetLabels()["alpha.eksctl.io/cluster-name"]; ok {
if clusterScrapeResult, ok := results[0].Config.(map[string]any); ok {
clusterScrapeResult["cluster-name"] = clusterName
}

relationships = append(relationships, v1.RelationshipResult{
ConfigExternalID: v1.ExternalID{
ExternalID: []string{string(obj.GetUID())},
ConfigType: ConfigTypePrefix + "Node",
},
RelatedExternalID: v1.ExternalID{
ExternalID: []string{clusterName},
ConfigType: "AWS::EKS::Cluster",
},
Relationship: "EKSClusterNode",
})
}
}

if obj.GetNamespace() != "" {
relationships = append(relationships, v1.RelationshipResult{
ConfigExternalID: v1.ExternalID{
Expand Down Expand Up @@ -191,9 +211,9 @@ func (kubernetes KubernetesScraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResul
accountID = extractAccountIDFromARN(mapRolesYAML)
}

if v, ok := results[0].Config.(map[string]any); ok {
v["aws-auth"] = cm
v["account-id"] = accountID
if clusterScrapeResult, ok := results[0].Config.(map[string]any); ok {
clusterScrapeResult["aws-auth"] = cm
clusterScrapeResult["account-id"] = accountID
}
}
}
Expand Down

0 comments on commit 3187624

Please sign in to comment.