-
Notifications
You must be signed in to change notification settings - Fork 701
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
chore: add descheduler plugin example #1636
chore: add descheduler plugin example #1636
Conversation
Welcome @ricardomaraschini! |
Hi @ricardomaraschini. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This should address #923 |
/cc |
/ok-to-test |
This commit adds a sample plugin implementation as follow: This directory provides an example plugin for the Kubernetes Descheduler, demonstrating how to evict pods based on custom criteria. The plugin targets pods based on: * **Name Regex:** Pods matching a specified regular expression. * **Age:** Pods older than a defined duration. * **Namespace:** Pods within or outside a given list of namespaces (inclusion or exclusion). To incorporate this plugin into your Descheduler build, you must register it within the Descheduler's plugin registry. Follow these steps: 1. **Register the Plugin:** * Modify the `pkg/descheduler/setupplugins.go` file. * Add the following registration line to the end of the `RegisterDefaultPlugins()` function: ```go pluginregistry.Register( example.PluginName, example.New, &example.Example{}, &example.ExampleArgs{}, example.ValidateExampleArgs, example.SetDefaults_Example, registry, ) ``` 2. **Generate Code:** * If you modify the plugin's code, execute `make gen` before rebuilding the Descheduler. This ensures generated code is up-to-date. 3. **Rebuild the Descheduler:** * Build the descheduler with your changes. Configure the plugin's behavior using the Descheduler's policy configuration. Here's an example: ```yaml apiVersion: descheduler/v1alpha2 kind: DeschedulerPolicy profiles: - name: LifecycleAndUtilization plugins: deschedule: enabled: - Example pluginConfig: - name: Example args: regex: ^descheduler-test.*$ maxAge: 3m namespaces: include: - default ``` - `regex: ^descheduler-test.*$`: Evicts pods whose names match the regular expression `^descheduler-test.*$`. - `maxAge: 3m`: Evicts pods older than 3 minutes. - `namespaces.include: - default`: Evicts pods within the default namespace. This configuration will cause the plugin to evict pods that meet all three criteria: matching the `regex`, exceeding the `maxAge`, and residing in the specified namespace.
0fa2e5f
to
57a04aa
Compare
This looks really great :) Thank you. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ingvagabund The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This commit adds a sample plugin implementation as follow:
Descheduler Plugin: Example Implementation
This directory provides an example plugin for the Kubernetes Descheduler, demonstrating how to evict pods based on custom criteria. The plugin targets pods based on:
Building and Integrating the Plugin
To incorporate this plugin into your Descheduler build, you must register it within the Descheduler's plugin registry. Follow these steps:
Register the Plugin:
pkg/descheduler/setupplugins.go
file.RegisterDefaultPlugins()
function:Generate Code:
make gen
before rebuilding the Descheduler. This ensures generated code is up-to-date.Rebuild the Descheduler:
Plugin Configuration
Configure the plugin's behavior using the Descheduler's policy configuration. Here's an example:
Explanation
regex: ^descheduler-test.*$
: Evicts pods whose names match the regular expression^descheduler-test.*$
.maxAge: 3m
: Evicts pods older than 3 minutes.namespaces.include: - default
: Evicts pods within the default namespace.This configuration will cause the plugin to evict pods that meet all three criteria: matching the
regex
, exceeding themaxAge
, and residing in the specified namespace.Notes
ExampleArgs
struct, which defines the plugin's parameters.Args
struct.ExampleArgs
struct reflect directly into theDeschedulerPolicy
configuration.DeschedulePlugin
interface to be registered with the Descheduler.Deschedule()
method, which is called by the Descheduler when the plugin is executed.make gen
.