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
- Methods:
ExtendedHandle (Extended handle interface)
- Methods:
Scheduler(),KoordinatorClientSet(),KoordinatorSharedInformerFactory(),RegisterErrorHandlerFilters(),RegisterForgetPodHandler(),GetReservationNominator(),GetNetworkTopologyTreeManager()
- Methods:
FrameworkExtenderFactory (Framework extender factory)
- Methods:
NewFrameworkExtender(),GetExtender(),InitScheduler(),PluginFactoryProxy(),updatePlugins() - Creates frameworkExtenderImpl
- Uses PluginFactoryProxy
- Methods:
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:
- RunReservationExtensionPreRestoreReservation
- RestoreReservation (matched/unmatched)
- RunReservationFilterPlugins
- RunReservationScorePlugins
- 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:
- Load ClusterColocationProfiles
- Match Profiles to Pod
- Sort Profiles by Name (if matched)
- Apply Mutations from Profiles
- 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:
- Define Plugin Interface: Implement appropriate extension interfaces
- Register Plugin: Use PluginFactoryProxy mechanism
- Implement Business Logic: Develop core functionality
- Handle Configuration: Support configuration through plugin arguments
- 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:
| Issue | Symptoms | Resolution |
|---|---|---|
| Plugin Not Registered | Logic not executed | Verify PluginFactoryProxy registration and feature gates |
| Configuration Problems | Initialization failure | Check plugin arguments and configuration schema |
| Extension Point Not Triggered | Expected logic not executed | Verify plugin enabled in scheduler configuration |
| Performance Issues | Increased scheduling latency | Optimize plugin logic, consider async operations |
| Compatibility Problems | Conflicts with other plugins | Review 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