Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
๐ค Generated by Copilot at d5f5b71
Summary
๐ฎ๐ก๏ธ๐
This pull request adds support for Nvidia GPU resources in the
sealos
controller. It defines GPU-related constants, types, and functions in thegpu
package, and uses them to create, price, and monitor GPU resources in theresources.go
andmonitor_controller.go
files. It also updates the RBAC and deployment configurations for themonitor-controller
controller to allow it to access node information.Walkthrough
nvidia.go
(link)gpu
package and add a new constantResourceGPU
and a new functionNewGpuResource
toresources.go
(link,link)ResourceGPU
constant to thePricesUnit
map inresources.go
to define the unit price for GPU resources (link)role.yaml
anddeploy.yaml
to allow themonitor
role and themonitor-controller
controller to get, list, and watch nodes (link,link)gpu
package and add a new fieldNvidiaGpu
to theMonitorReconciler
struct inmonitor_controller.go
(link,link)kubebuilder
annotation tomonitor_controller.go
to generate RBAC rules for accessing nodes (link)NewMonitorReconciler
function inmonitor_controller.go
to call theGetNodeGpuModel
function from thegpu
package and assign the result to theNvidiaGpu
field (link)podResourceUsage
function inmonitor_controller.go
to handle the GPU resource usage from pods by checking the GPU limit, getting the GPU model, and adding the GPU request to thers
map (link)getResourceValue
function inmonitor_controller.go
to convert the GPU resource usage to integer values based on the unit price (link)initResources
function inmonitor_controller.go
to initialize thers
map with zero values for theResourceGPU
constant (link)hasStorageQuota
to indicate whether the namespace has a resource quota for storage in thepodResourceUsage
function inmonitor_controller.go
(link)UserAnnotationOwnerKey
annotation and log an error if the resource quota is empty in thepodResourceUsage
function inmonitor_controller.go
(link)rs
map if the namespace does not have a storage quota in thepodResourceUsage
function inmonitor_controller.go
(link)