From e85da803733c4a93d8e983d38a38a5b184c09d15 Mon Sep 17 00:00:00 2001 From: Andre Ziviani Date: Sat, 18 Mar 2023 14:14:59 -0300 Subject: [PATCH] fix: fargate cost --- exporter/kubernetes.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exporter/kubernetes.go b/exporter/kubernetes.go index 19fde8e..0c7a579 100644 --- a/exporter/kubernetes.go +++ b/exporter/kubernetes.go @@ -232,7 +232,7 @@ func (m *Metrics) nodeCreated(obj interface{}) { } else if _, ok := node.Labels["eks.amazonaws.com/compute-type"]; ok && node.Labels["eks.amazonaws.com/compute-type"] == "fargate" { // Fargate tmp.Instance = m.Instances["fargate"] - tmp.Cost = tmp.Instance.OnDemandCost + tmp.Cost = &Ec2Cost{Type: "fargate", VCpu: tmp.Instance.OnDemandCost.VCpu, Memory: tmp.Instance.OnDemandCost.VCpu} } m.nodesMtx.Lock() @@ -284,6 +284,13 @@ func (m *Metrics) GetUsageCost() { } m.updatePodCost(me) + + if me.Node.Instance.Type == "fargate" { + // Also update node cost + me.Node.Cost.VCpu = me.VCpuCost + me.Node.Cost.Memory = me.MemoryCost + me.Node.Cost.Total = me.Cost + } } }