Skip to content

Add NodeMetadata scoring plugin#942

Open
alikhil wants to merge 1 commit intokubernetes-sigs:masterfrom
criteo-forks:alik-master
Open

Add NodeMetadata scoring plugin#942
alikhil wants to merge 1 commit intokubernetes-sigs:masterfrom
criteo-forks:alik-master

Conversation

@alikhil
Copy link
Copy Markdown

@alikhil alikhil commented Dec 12, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR introduces new score plugin which allows you to influence scheduling decisions based on custom node metadata. It supports two types of metadata:

  1. Numeric values - Score nodes based on numeric labels/annotations
  2. Timestamps - Score nodes based on timestamp labels/annotations
Use Cases
  1. Cost Optimization - Prefer cheaper nodes
  2. Hardware Generation - Prefer newer or older hardware
  3. Maintenance Windows - Avoid recently maintained or prefer well-maintained nodes
  4. Custom Priorities - Implement business-specific node prioritization
  5. Node Aging - Distribute workloads based on node age
  6. Performance Tiers - Score nodes by performance benchmarks
Behavior Notes
  • If a node doesn't have the specified metadata key, it receives a score of 0 (lowest)
  • Scores are normalized to the range [0, 100] (framework.MinNodeScore to framework.MaxNodeScore)
  • The plugin can be combined with other scoring plugins using weighted scores
  • Invalid metadata values (e.g., unparseable timestamps) result in a score of 0 for that node
Arguments

The plugin accepts the following configuration parameters:

Parameter Type Required Description
metadataKey string Yes The name of the label or annotation to use for scoring
metadataSource string Yes Where to read metadata from: "Label" or "Annotation"
metadataType string Yes Type of metadata value: "Number" or "Timestamp"
scoringStrategy string Yes How to score nodes (see below)
timestampFormat string Conditional Go time format string (required when metadataType is "Timestamp")
Example Score by Last Update Time (Newest Timestamp)

Prefer nodes that were updated most recently:

apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
profiles:
  - schedulerName: default-scheduler
    plugins:
      score:
        enabled:
          - name: NodeMetadata
    pluginConfig:
      - name: NodeMetadata
        args:
          metadataKey: "node.example.com/last-maintenance"
          metadataSource: "Annotation"
          metadataType: "Timestamp"
          scoringStrategy: "Newest"
          timestampFormat: "2006-01-02T15:04:05Z07:00"  # RFC3339

Node annotations:

apiVersion: v1
kind: Node
metadata:
  name: node1
  annotations:
    node.example.com/last-maintenance: "2025-12-01T10:00:00Z"
---
apiVersion: v1
kind: Node
metadata:
  name: node2
  annotations:
    node.example.com/last-maintenance: "2025-12-03T10:00:00Z"

Result: node2 gets a higher score than node1 (more recently maintained).

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Add NodeMetadata scoring plugin

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Dec 12, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Dec 12, 2025

Deploy Preview for kubernetes-sigs-scheduler-plugins canceled.

Name Link
🔨 Latest commit bbb3443
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-scheduler-plugins/deploys/693c18bd0f4890000849986d

@k8s-ci-robot k8s-ci-robot added do-not-merge/contains-merge-commits cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 12, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @alikhil!

It looks like this is your first PR to kubernetes-sigs/scheduler-plugins 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/scheduler-plugins has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 12, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @alikhil. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alikhil
Once this PR has been reviewed and has the lgtm label, please assign denkensk for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 12, 2025
Signed-off-by: Alik Khilazhev <7482065+alikhil@users.noreply.github.com>
@ffromani
Copy link
Copy Markdown
Contributor

/cc

@PiotrProkop
Copy link
Copy Markdown
Contributor

can you add a bit longer description? What does this plugin tries to do? What are the usecases?

@alikhil
Copy link
Copy Markdown
Author

alikhil commented Dec 16, 2025

@PiotrProkop I have added more details to the PR description. You can also refer to the plugin’s README.md for additional information.

@alikhil
Copy link
Copy Markdown
Author

alikhil commented Jan 7, 2026

Friendly ping when you have a moment — I’d appreciate any feedback. Thanks!

@josqu4red
Copy link
Copy Markdown

Hello, co-owner of the fork here, can we do anything to help get this change reviewed? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants