Skip to main content
Version: v1.7

Extensibility

Introductionโ€‹

Koordinator provides a comprehensive extensibility framework for custom policies and QoS enforcement through scheduling plugins, webhook admission controllers, and runtime hooks. This document details plugin development, extension point architecture, and practical implementation for custom scheduling policies and QoS strategies.

Plugin Architecture and Registrationโ€‹

Koordinator's plugin architecture builds on an enhanced Kubernetes scheduling framework with additional extension points while maintaining compatibility. Uses a factory pattern for plugin registration that intercepts initialization to inject extended functionality.

Framework Extender Class Structure:

Core components and relationships:

  • FrameworkExtender (Framework extender interface)

    • Methods: SetConfiguredPlugins(), RunReservationExtensionPreRestoreReservation(), RunReservationExtensionRestoreReservation(), RunReservationScorePlugins(), RunReservationFilterPlugins(), RunNUMATopologyManagerAdmit(), RunAllocatePlugins()
    • Contains ExtendedHandle
  • ExtendedHandle (Extended handle interface)

    • Methods: Scheduler(), KoordinatorClientSet(), KoordinatorSharedInformerFactory(), RegisterErrorHandlerFilters(), RegisterForgetPodHandler(), GetReservationNominator(), GetNetworkTopologyTreeManager()
  • FrameworkExtenderFactory (Framework extender factory)

    • Methods: NewFrameworkExtender(), GetExtender(), InitScheduler(), PluginFactoryProxy(), updatePlugins()
    • Creates frameworkExtenderImpl
    • Uses PluginFactoryProxy

Relationships:

  • frameworkExtenderImpl implements FrameworkExtender and ExtendedHandle interfaces
  • FrameworkExtenderFactory creates and manages frameworkExtenderImpl

Diagram sources

Section sources

Scheduling Framework Extension Pointsโ€‹

The enhanced framework provides extension points for plugins to participate in scheduling at various stages. Extension points include transformer interfaces that modify scheduling objects before core operations, reservation-specific plugins for resource reservations, and specialized scoring/filtering mechanisms.

Transformer Extension Pointsโ€‹

Transformer plugins modify scheduling objects (Pods and NodeInfo) before core operations at specific cycle phases:

  • BeforePreFilter โ†’ Core PreFilter โ†’ AfterPreFilter
  • BeforeFilter โ†’ Core Filter
  • BeforeScore โ†’ Core Score
  • AllocatePlugins (at Reserve phase)
  • Bind Phase

Transformer Extension Point Execution Flow:

Scheduling Cycle Phases:

1. Scheduling Cycle Start
โ†“
2. PreFilter Phase
โ”œโ”€ BeforePreFilter Transformers
โ”œโ”€ Core PreFilter Plugins
โ””โ”€ AfterPreFilter Transformers
โ†“
3. Filter Phase
โ”œโ”€ BeforeFilter Transformers
โ””โ”€ Core Filter Plugins
โ†“
4. Score Phase
โ”œโ”€ BeforeScore Transformers
โ””โ”€ Core Score Plugins
โ†“
5. Reserve Phase
โ””โ”€ Allocate Plugins
โ†“
6. Bind Phase

Section sources

Reservation Management Extension Pointsโ€‹

Koordinator provides specialized extension points for reservation-based scheduling:

  1. RunReservationExtensionPreRestoreReservation
  2. RestoreReservation (matched/unmatched)
  3. RunReservationFilterPlugins
  4. RunReservationScorePlugins
  5. NominateReservation

Reservation Management Extension Point Interaction Flow:

Participants:
- Pod to Schedule (pod to be scheduled)
- FrameworkExtender (framework extender)
- Reservation Plugin (reservation plugin)

Flow:

1. Pod โ†’ FrameworkExtender: Schedule Request

2. FrameworkExtender: Execute RunReservationExtensionPreRestoreReservation

3. FrameworkExtender โ†’ ReservationPlugin: RestoreReservation(matched/unmatched)

4. ReservationPlugin โ†’ FrameworkExtender: Return PluginToReservationRestoreStates

5. FrameworkExtender: Execute RunReservationFilterPlugins

6. FrameworkExtender โ†’ ReservationPlugin: FilterReservation

7. ReservationPlugin โ†’ FrameworkExtender: Return Filter Status

8. FrameworkExtender: Execute RunReservationScorePlugins

9. FrameworkExtender โ†’ ReservationPlugin: ScoreReservation

10. ReservationPlugin โ†’ FrameworkExtender: Return Reservation Scores

11. FrameworkExtender: Execute NominateReservation

12. FrameworkExtender โ†’ Pod: Return Selected Node and Reservation

Diagram sources

Webhook Extension Systemโ€‹

Koordinator's webhook system provides admission control through mutating and validating webhooks, built on controller-runtime with feature-gated functionality.

Webhook Architectureโ€‹

The webhook server architecture follows a modular design with centralized registration and feature-based activation:

Webhook Server Architecture:

API Server
โ†“ (requests)
Webhook Server
โ”œโ”€โ”€ Handler Registry
โ”‚ โ”œโ”€โ”€ Pod Webhooks
โ”‚ โ”œโ”€โ”€ Node Webhooks
โ”‚ โ””โ”€โ”€ Reservation Webhooks
โ””โ”€โ”€ Health Checker

Diagram sources

Cluster Colocation Profile Webhookโ€‹

The cluster colocation profile webhook demonstrates mutation logic applying QoS policies and resource configurations based on matching criteria. Workflow:

  1. Load ClusterColocationProfiles
  2. Match Profiles to Pod
  3. Sort Profiles by Name (if matched)
  4. Apply Mutations from Profiles
  5. Handle Resource Specifications

Cluster Colocation Profile Webhook Processing Flow:

1. Admission Request
โ†“
2. Load ClusterColocationProfiles
โ†“
3. Match Profiles to Pod
โ†“
4. Profiles Matched?
โ”œโ”€ No โ†’ Allow Request
โ””โ”€ Yes โ†’ Continue
โ†“
5. Sort Profiles by Name
โ†“
6. Apply Mutations from Profiles
โ†“
7. Handle Resource Specifications
โ†“
8. Complete Request

Section sources

QoS Enforcement and Policy Pluginsโ€‹

Koordinator's QoS enforcement combines webhook mutations and scheduling framework plugins. The system applies QoS policies at admission time and enforces them during scheduling.

QoS Policy Application Flowโ€‹

The QoS policy application follows a multi-stage process that begins with webhook mutation and continues through the scheduling pipeline:

QoS Policy Application Flow:

Participants:
- User
- API Server
- Koordinator Webhook
- Koordinator Scheduler

Flow:

1. User โ†’ API Server: Create Pod

2. API Server โ†’ Koordinator Webhook: Admission Review

3. Koordinator Webhook internal processing:
- Match ClusterColocationProfiles
- Apply QoS Labels and Annotations
- Transform Resource Specifications

4. Koordinator Webhook โ†’ API Server: Patch Operations

5. API Server internal: Apply Patches

6. API Server โ†’ Koordinator Scheduler: Schedule Pod

7. Koordinator Scheduler internal processing:
- Apply QoS-aware Scheduling
- Enforce Resource Isolation

8. Koordinator Scheduler โ†’ User: Pod Scheduled

Section sources

Development and Testing Guidelinesโ€‹

Developing custom plugins requires understanding plugin registration, extension interfaces, and testing methodologies.

Plugin Development Process:

  1. Define Plugin Interface: Implement appropriate extension interfaces
  2. Register Plugin: Use PluginFactoryProxy mechanism
  3. Implement Business Logic: Develop core functionality
  4. Handle Configuration: Support configuration through plugin arguments
  5. Implement Testing: Create unit and integration tests

Testing Strategies: Multiple approaches required:

  • Unit Testing: Mock dependencies for plugin business logic
  • Integration Testing: Test with real components for framework integration
  • End-to-End Testing: Validate system behavior in cluster

Plugin Testing Strategy Levels:

Testing Levels:

1. Unit Testing
- Uses Mocks
- Tests Plugin Business Logic

2. Integration Testing
- Uses Real Components
- Tests Framework Integration

3. End-to-End Testing
- Uses Cluster Environment
- Tests System Behavior

Section sources

Troubleshooting Plugin Developmentโ€‹

Common issues when developing Koordinator plugins:

IssueSymptomsResolution
Plugin Not RegisteredLogic not executedVerify PluginFactoryProxy registration and feature gates
Configuration ProblemsInitialization failureCheck plugin arguments and configuration schema
Extension Point Not TriggeredExpected logic not executedVerify plugin enabled in scheduler configuration
Performance IssuesIncreased scheduling latencyOptimize plugin logic, consider async operations
Compatibility ProblemsConflicts with other pluginsReview plugin ordering and dependencies

Diagnostic Tools:

  • Debug Flags: Enable debug output for filter/score results
  • Metrics Collection: Monitor plugin execution duration and success rates
  • Log Analysis: Examine detailed logs for execution flow
  • API Inspection: Use exposed REST APIs to inspect scheduler state | Plugin Not Registered | Plugin logic not executed | Verify PluginFactoryProxy registration and feature gate settings | | Configuration Problems | Plugin fails to initialize | Check plugin arguments and configuration schema | | Extension Point Not Triggered | Expected logic not executed | Verify plugin is enabled in the scheduler configuration | | Performance Issues | Scheduling latency increased | Optimize plugin logic and consider asynchronous operations | | Compatibility Problems | Conflicts with other plugins | Review plugin ordering and dependencies |

Diagnostic Toolsโ€‹

Koordinator provides several diagnostic tools for troubleshooting plugin issues:

  • Debug Flags: Enable debug output for filter and score results
  • Metrics Collection: Monitor plugin execution duration and success rates
  • Log Analysis: Examine detailed logs for plugin execution flow
  • API Inspection: Use the exposed REST APIs to inspect internal scheduler state

Section sources