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

Idle Node Plugin Enhancement #737

Closed
qmhu opened this issue Apr 25, 2023 · 2 comments · Fixed by #775
Closed

Idle Node Plugin Enhancement #737

qmhu opened this issue Apr 25, 2023 · 2 comments · Fixed by #775
Labels
bootcamp help wanted Extra attention is needed

Comments

@qmhu
Copy link
Member

qmhu commented Apr 25, 2023

Describe the feature

Find idle node with following rules:

  • cpu/memory request rate
  • cpu/memory utilization rate

It need to implement some configuration for this plugin:

  • cpu-request-utilization
  • cpu-usage-utilization
  • memory-request-utilization
  • memory-usage-utilization
@qmhu qmhu added the help wanted Extra attention is needed label Apr 25, 2023
@github-actions
Copy link
Contributor

Hello @qmhu.
We totally like your proposal/feedback, welcome to send us a Pull Request for it.
Please send your Pull Request to main branch, fill the Pull Request Template here, provide changelog/documentation/test cases if needed and make sure CI passed, we will review it soon.
We appreciate your effort in advance and looking forward to your contribution!

你好 @qmhu,我们完全同意你的提议/反馈。
欢迎直接在此仓库 创建一个 Pull Request 来解决这个问题。
请将 Pull Request 发到 main 分支,务必填写 Pull Request 内的预设模板,提供改动所需相应的 changelog、测试用例、文档等,并确保 CI 通过。
我们会尽快进行 Review,提前感谢和期待您的贡献。

@qmhu
Copy link
Member Author

qmhu commented May 15, 2023

To implement the feature of finding idle nodes in the Crane open-source project based on CPU and memory request/utilization rates, you can follow these steps:

  1. Clone the Crane repository: Start by cloning the Crane repository from GitHub using the following command:

    git clone https://github.com/gocrane/crane.git
    
  2. Navigate to the plugin directory: Change your working directory to the plugins folder within the Crane project.

  3. Create a new Go file: Create a new Go file, such as idle_nodes.go, in the plugins directory.

  4. Implement the idle nodes plugin: In the idle_nodes.go file, you'll need to implement the logic to find idle nodes based on the provided rules. Here's a basic example to get you started:

    package main
    
    import (
    	"fmt"
    	"log"
    
    	"github.com/gocrane/crane/api"
    	"github.com/gocrane/crane/executor"
    )
    
    func main() {
    	// Initialize Crane executor
    	executor := executor.NewDefaultExecutor()
    
    	// Get all nodes
    	nodes, err := executor.GetNodes()
    	if err != nil {
    		log.Fatal("Failed to get nodes:", err)
    	}
    
    	// Iterate over each node and check utilization
    	for _, node := range nodes {
    		cpuRequestUtilization := node.CPURequestUtilization()
    		cpuUsageUtilization := node.CPUUsageUtilization()
    		memoryRequestUtilization := node.MemoryRequestUtilization()
    		memoryUsageUtilization := node.MemoryUsageUtilization()
    
    		// Check if the node meets the configuration criteria
    		if cpuRequestUtilization < cpuRequestUtilizationThreshold &&
    			cpuUsageUtilization < cpuUsageUtilizationThreshold &&
    			memoryRequestUtilization < memoryRequestUtilizationThreshold &&
    			memoryUsageUtilization < memoryUsageUtilizationThreshold {
    			fmt.Println("Idle node:", node.Name)
    		}
    	}
    }

    In this example, we're using the Crane executor to retrieve all nodes and check their CPU and memory request/utilization rates against the provided thresholds. If a node meets the criteria, it's considered an idle node.

  5. Configure the plugin: Define the configuration values for the CPU and memory request/utilization thresholds (cpu-request-utilization, cpu-usage-utilization, memory-request-utilization, memory-usage-utilization) based on your specific requirements. These thresholds will be used to determine if a node is idle.

  6. Build and run the plugin: Build the Crane project with your custom plugin using the following command:

    go build -o crane .
    
  7. Run the plugin: Execute the Crane binary to run the plugin and find the idle nodes in your cluster:

    ./crane plugin idle_nodes
    

    The output will display the names of any idle nodes that meet the specified CPU and memory request/utilization rate criteria.

By following these steps, you can extend the Crane open-source project with a custom plugin to find idle nodes in your Kubernetes cluster based on CPU and memory request/utilization rates. Adjust the configuration and thresholds as per your specific needs.

Is this generate from gpt?

@qmhu qmhu closed this as completed in #775 May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bootcamp help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant