Skip to content

Commit

Permalink
use fargate profile from pod as node.nodegroup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexei-led committed May 18, 2023
1 parent a2968e7 commit c051101
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/usage/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ func patchFargateNodeInfo(pod *v1.Pod, node *NodeInfo) error {
// update node instance type: "fargate-{CapacityProvisioned}", e.g. "fargate-0.25vCPU-0.5GB"
node.InstanceType = fmt.Sprintf("%s-%s", fargateType, strings.ReplaceAll(capacityProvisioned, " ", "-"))
}
// get Fargate profile name from pod label "eks.amazonaws.com/fargate-profile"
// and patch node nodegroup name
if fargateProfileName, ok := pod.Labels["eks.amazonaws.com/fargate-profile"]; ok {
node.Nodegroup = fargateProfileName
}
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions internal/usage/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ func TestPatchFargateNodeInfo(t *testing.T) {
Annotations: map[string]string{
"CapacityProvisioned": "0.25vCPU 0.5GB",
},
Labels: map[string]string{
"eks.amazonaws.com/fargate-profile": "fp-1",
},
},
},
node: &NodeInfo{
Expand All @@ -293,6 +296,7 @@ func TestPatchFargateNodeInfo(t *testing.T) {
expectedNodeAllocatable: NodeInfo{
ComputeType: fargateType,
InstanceType: "fargate-0.25vCPU-0.5GB",
Nodegroup: "fp-1",
Allocatable: Capacity{
CPU: 250,
Memory: 244 * int64(math.Pow10(6)), // 0.244GB
Expand Down

0 comments on commit c051101

Please sign in to comment.