From ac017acd5ec2dc2f4cd9e165b75405671b4e8680 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Thu, 17 Oct 2024 12:12:49 +0545 Subject: [PATCH] fix: kubernetes node pod relationship --- scrapers/kubernetes/hook_aws.go | 2 +- scrapers/kubernetes/kubernetes.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scrapers/kubernetes/hook_aws.go b/scrapers/kubernetes/hook_aws.go index d0e83093..1917f6cc 100644 --- a/scrapers/kubernetes/hook_aws.go +++ b/scrapers/kubernetes/hook_aws.go @@ -41,7 +41,7 @@ func (aws AWS) OnObject(ctx *KubernetesContext, obj *unstructured.Unstructured) } } if obj.GetKind() == "Pod" && obj.GetLabels()["app.kubernetes.io/name"] == "aws-node" { - nodeName := getString(obj, "spec.nodeName") + nodeName := getString(obj, "spec", "nodeName") spec := obj.Object["spec"].(map[string]interface{}) for _, ownerRef := range obj.GetOwnerReferences() { if ownerRef.Kind == "DaemonSet" && ownerRef.Name == "aws-node" { diff --git a/scrapers/kubernetes/kubernetes.go b/scrapers/kubernetes/kubernetes.go index 849e0a4e..764f5aaa 100644 --- a/scrapers/kubernetes/kubernetes.go +++ b/scrapers/kubernetes/kubernetes.go @@ -42,8 +42,7 @@ func getConfigTypePrefix(apiVersion string) string { return ConfigTypePrefix } -type KubernetesScraper struct { -} +type KubernetesScraper struct{} func (kubernetes KubernetesScraper) CanScrape(configs v1.ScraperSpec) bool { return len(configs.Kubernetes) > 0 @@ -298,7 +297,7 @@ func ExtractResults(ctx *KubernetesContext, objs []*unstructured.Unstructured) v } if obj.GetKind() == "Pod" { - nodeName := getString(obj, "spec.nodeName") + nodeName := getString(obj, "spec", "nodeName") if nodeName != "" { nodeID := ctx.GetID("", "Node", nodeName)