Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[civo] Add Gpu count to node template #6390

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cluster-autoscaler/cloudprovider/civo/civo_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func getCivoNodeTemplate(pool civocloud.KubernetesPool, client nodeGroupClient)
template.Labels = pool.Labels
template.Region = pool.Region
template.Taints = pool.Taints
template.GpuCount = size.GPUCount

return template
}
5 changes: 4 additions & 1 deletion cluster-autoscaler/cloudprovider/civo/civo_node_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
autoscaler "k8s.io/autoscaler/cluster-autoscaler/config"
"k8s.io/autoscaler/cluster-autoscaler/utils/gpu"
"k8s.io/klog/v2"
schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
)
Expand Down Expand Up @@ -55,6 +56,7 @@ type CivoNodeTemplate struct {
DiskGigabytes int `json:"disk_gb,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Taints []apiv1.Taint `json:"taint,omitempty"`
GpuCount int `json:"gpu_count,omitempty"`
Region string `json:"region,omitempty"`
}

Expand Down Expand Up @@ -301,7 +303,8 @@ func (n *NodeGroup) buildNodeFromTemplate(name string, template *CivoNodeTemplat
node.Status.Capacity[apiv1.ResourcePods] = *resource.NewQuantity(110, resource.DecimalSI)
node.Status.Capacity[apiv1.ResourceCPU] = *resource.NewQuantity(int64(template.CPUCores*1000), resource.DecimalSI)
node.Status.Capacity[apiv1.ResourceMemory] = *resource.NewQuantity(int64(template.RAMMegabytes*1024*1024), resource.DecimalSI)
node.Status.Capacity[apiv1.ResourceEphemeralStorage] = *resource.NewQuantity(int64(template.DiskGigabytes*1024*1024), resource.DecimalSI)
node.Status.Capacity[apiv1.ResourceEphemeralStorage] = *resource.NewQuantity(int64(template.DiskGigabytes*1024*1024*1024), resource.DecimalSI)
node.Status.Capacity[gpu.ResourceNvidiaGPU] = *resource.NewQuantity(int64(template.GpuCount), resource.DecimalSI)

node.Status.Allocatable = node.Status.Capacity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func TestNodeGroup_TemplateNodeInfo(t *testing.T) {
assert.Equal(t, len(nodeInfo.Pods), 1, "should have one template pod")
assert.Equal(t, nodeInfo.Node().Status.Capacity.Cpu().ToDec().Value(), int64(1000), "should match cpu capacity ")
assert.Equal(t, nodeInfo.Node().Status.Capacity.Memory().ToDec().Value(), int64(1073741824), "should match memory capacity")
assert.Equal(t, nodeInfo.Node().Status.Capacity.StorageEphemeral().ToDec().Value(), int64(20971520), "should match epheral storage capacity")
assert.Equal(t, nodeInfo.Node().Status.Capacity.StorageEphemeral().ToDec().Value(), int64(21474836480), "should match epheral storage capacity")
assert.Equal(t, nodeInfo.Node().Labels["id"], "id", "should match labels")
assert.Equal(t, nodeInfo.Node().Labels["kubernetes.civo.com/civo-node-pool"], "1", "should match labels")
assert.Equal(t, nodeInfo.Node().Labels["kubernetes.io/os"], "linux", "should match labels")
Expand Down
Loading