Documentation
¶
Index ¶
- type AffinityOperator
- type AffinityRule
- type BinPackingStrategy
- type Constraint
- type EnhancedConstraint
- type EnhancedNode
- type EnhancedResourceLimit
- type EnhancedResourceRequest
- type EnhancedResourceRequirements
- type EnhancedScheduler
- func (s *EnhancedScheduler) Close() error
- func (s *EnhancedScheduler) RegisterNode(node *EnhancedNode)
- func (s *EnhancedScheduler) Schedule(ctx context.Context, task *Task) (string, error)
- func (s *EnhancedScheduler) ScheduleAll(ctx context.Context) error
- func (s *EnhancedScheduler) ScheduleTask(ctx context.Context, task *Task) (string, error)
- func (s *EnhancedScheduler) SubmitTask(task *EnhancedTask)
- func (s *EnhancedScheduler) UnregisterNode(nodeID string)
- func (s *EnhancedScheduler) WithBinPackingStrategy(strategy BinPackingStrategy) *EnhancedScheduler
- func (s *EnhancedScheduler) WithNodeManager(nodeManager interface{}) *EnhancedScheduler
- func (s *EnhancedScheduler) WithOvercommitRatios(cpuRatio, memoryRatio float64) *EnhancedScheduler
- func (s *EnhancedScheduler) WithRebalanceThreshold(threshold float64) *EnhancedScheduler
- func (s *EnhancedScheduler) WithSchedulingInterval(interval int64) *EnhancedScheduler
- type EnhancedTask
- type EnhancedTaskState
- type LabelConstraint
- type Node
- type NodeLoad
- type RegionConstraint
- type ResourceRequirements
- type Scheduler
- func (s *Scheduler) GetNode(nodeID string) (*Node, bool)
- func (s *Scheduler) GetTask(taskID string) (*Task, bool)
- func (s *Scheduler) RegisterNode(node *Node)
- func (s *Scheduler) Schedule(ctx context.Context) error
- func (s *Scheduler) SubmitTask(task *Task)
- func (s *Scheduler) UnregisterNode(nodeID string)
- type Taint
- type TaintEffect
- type Task
- type TaskState
- type Toleration
- type ZoneConstraint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AffinityOperator ¶
type AffinityOperator string
AffinityOperator represents an operator for affinity rules
const ( // AffinityOperatorIn represents the "in" operator AffinityOperatorIn AffinityOperator = "In" // AffinityOperatorNotIn represents the "not in" operator AffinityOperatorNotIn AffinityOperator = "NotIn" // AffinityOperatorExists represents the "exists" operator AffinityOperatorExists AffinityOperator = "Exists" // AffinityOperatorDoesNotExist represents the "does not exist" operator AffinityOperatorDoesNotExist AffinityOperator = "DoesNotExist" )
type AffinityRule ¶
type AffinityRule struct {
Key string
Operator AffinityOperator
Values []string
}
AffinityRule represents a rule for node affinity
type BinPackingStrategy ¶
type BinPackingStrategy string
BinPackingStrategy represents different strategies for bin packing
const ( // BinPackingBestFit packs tasks onto as few nodes as possible BinPackingBestFit BinPackingStrategy = "BestFit" // BinPackingWorstFit spreads tasks across nodes evenly BinPackingWorstFit BinPackingStrategy = "WorstFit" // BinPackingFirstFit uses the first node that fits BinPackingFirstFit BinPackingStrategy = "FirstFit" // BinPackingRandom randomly selects a node that fits BinPackingRandom BinPackingStrategy = "Random" )
type Constraint ¶
Constraint represents a scheduling constraint
type EnhancedConstraint ¶
type EnhancedConstraint interface {
Satisfied(node *EnhancedNode) bool
}
EnhancedConstraint represents a scheduling constraint
type EnhancedNode ¶
type EnhancedNode struct {
ID string
Name string
Address string
Available EnhancedResourceRequirements
Used EnhancedResourceRequirements
Labels map[string]string
Taints []Taint
Zone string
Region string
}
EnhancedNode represents a node in the cluster
type EnhancedResourceLimit ¶
EnhancedResourceLimit specifies the resource limits for a task
type EnhancedResourceRequest ¶
EnhancedResourceRequest specifies the resources requested by a task
type EnhancedResourceRequirements ¶
type EnhancedResourceRequirements struct {
Requests EnhancedResourceRequest
Limits EnhancedResourceLimit
}
EnhancedResourceRequirements specifies the resources required by a task
type EnhancedScheduler ¶
type EnhancedScheduler struct {
// contains filtered or unexported fields
}
EnhancedScheduler is responsible for scheduling tasks to nodes
func NewEnhancedScheduler ¶
func NewEnhancedScheduler(logger *logrus.Logger) (*EnhancedScheduler, error)
NewEnhancedScheduler creates a new enhanced scheduler
func (*EnhancedScheduler) Close ¶
func (s *EnhancedScheduler) Close() error
Close closes the scheduler and releases resources
func (*EnhancedScheduler) RegisterNode ¶
func (s *EnhancedScheduler) RegisterNode(node *EnhancedNode)
RegisterNode registers a node with the scheduler
func (*EnhancedScheduler) ScheduleAll ¶
func (s *EnhancedScheduler) ScheduleAll(ctx context.Context) error
ScheduleAll attempts to schedule all pending tasks to available nodes
func (*EnhancedScheduler) ScheduleTask ¶
ScheduleTask schedules a specific task to an available node
func (*EnhancedScheduler) SubmitTask ¶
func (s *EnhancedScheduler) SubmitTask(task *EnhancedTask)
SubmitTask submits a task to be scheduled
func (*EnhancedScheduler) UnregisterNode ¶
func (s *EnhancedScheduler) UnregisterNode(nodeID string)
UnregisterNode removes a node from the scheduler
func (*EnhancedScheduler) WithBinPackingStrategy ¶
func (s *EnhancedScheduler) WithBinPackingStrategy(strategy BinPackingStrategy) *EnhancedScheduler
WithBinPackingStrategy sets the bin packing strategy
func (*EnhancedScheduler) WithNodeManager ¶
func (s *EnhancedScheduler) WithNodeManager(nodeManager interface{}) *EnhancedScheduler
WithNodeManager sets the node manager
func (*EnhancedScheduler) WithOvercommitRatios ¶
func (s *EnhancedScheduler) WithOvercommitRatios(cpuRatio, memoryRatio float64) *EnhancedScheduler
WithOvercommitRatios sets the resource overcommit ratios
func (*EnhancedScheduler) WithRebalanceThreshold ¶
func (s *EnhancedScheduler) WithRebalanceThreshold(threshold float64) *EnhancedScheduler
WithRebalanceThreshold sets the load difference threshold for rebalancing
func (*EnhancedScheduler) WithSchedulingInterval ¶
func (s *EnhancedScheduler) WithSchedulingInterval(interval int64) *EnhancedScheduler
WithSchedulingInterval sets the scheduling interval in seconds
type EnhancedTask ¶
type EnhancedTask struct {
ID string
Name string
Image string
Command []string
Resources EnhancedResourceRequirements
State EnhancedTaskState
AssignedTo string
Constraints []EnhancedConstraint
Priority int32
TenantID string
Tolerations []Toleration
}
EnhancedTask represents a unit of work to be scheduled
type EnhancedTaskState ¶
type EnhancedTaskState string
EnhancedTaskState represents the state of a scheduled task
const ( // EnhancedTaskPending indicates the task is waiting to be scheduled EnhancedTaskPending EnhancedTaskState = "pending" // EnhancedTaskScheduled indicates the task has been scheduled to a node EnhancedTaskScheduled EnhancedTaskState = "scheduled" // EnhancedTaskRunning indicates the task is running on a node EnhancedTaskRunning EnhancedTaskState = "running" // EnhancedTaskCompleted indicates the task has completed successfully EnhancedTaskCompleted EnhancedTaskState = "completed" // EnhancedTaskFailed indicates the task has failed EnhancedTaskFailed EnhancedTaskState = "failed" )
type LabelConstraint ¶
LabelConstraint is a constraint that requires a specific label value
func (*LabelConstraint) Satisfied ¶
func (c *LabelConstraint) Satisfied(node *EnhancedNode) bool
Satisfied checks if the node satisfies the label constraint
type Node ¶
type Node struct {
ID string
Name string
Address string
Available ResourceRequirements
Used ResourceRequirements
Labels map[string]string
}
Node represents a node in the cluster
type NodeLoad ¶
type NodeLoad struct {
NodeID string
LoadScore float64
ContainerCount int
ReservedCPU float64
ReservedMemory int64
Taints []Taint
}
NodeLoad represents the current load on a node
type RegionConstraint ¶
type RegionConstraint struct {
Region string
}
RegionConstraint is a constraint that requires a specific region
func (*RegionConstraint) Satisfied ¶
func (c *RegionConstraint) Satisfied(node *EnhancedNode) bool
Satisfied checks if the node satisfies the region constraint
type ResourceRequirements ¶
ResourceRequirements specifies the resources required by a task
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is responsible for scheduling tasks to nodes
func NewScheduler ¶
NewScheduler creates a new scheduler
func (*Scheduler) RegisterNode ¶
RegisterNode registers a node with the scheduler
func (*Scheduler) SubmitTask ¶
SubmitTask submits a task to be scheduled
func (*Scheduler) UnregisterNode ¶
UnregisterNode removes a node from the scheduler
type Taint ¶
type Taint struct {
Key string
Value string
Effect TaintEffect
}
Taint represents a taint on a node
type TaintEffect ¶
type TaintEffect string
TaintEffect represents the effect of a taint
const ( // TaintEffectNoSchedule prevents scheduling of new tasks TaintEffectNoSchedule TaintEffect = "NoSchedule" // TaintEffectPreferNoSchedule tries to avoid scheduling but not guaranteed TaintEffectPreferNoSchedule TaintEffect = "PreferNoSchedule" // TaintEffectNoExecute evicts tasks that don't tolerate the taint TaintEffectNoExecute TaintEffect = "NoExecute" )
type Task ¶
type Task struct {
ID string
Name string
Image string
Command []string
Resources ResourceRequirements
State TaskState
AssignedTo string
Constraints []Constraint
Affinity []AffinityRule
}
Task represents a unit of work to be scheduled
type TaskState ¶
type TaskState string
TaskState represents the state of a scheduled task
const ( // TaskPending indicates the task is waiting to be scheduled TaskPending TaskState = "pending" // TaskScheduled indicates the task has been scheduled to a node TaskScheduled TaskState = "scheduled" // TaskRunning indicates the task is running on a node TaskRunning TaskState = "running" // TaskCompleted indicates the task has completed successfully TaskCompleted TaskState = "completed" // TaskFailed indicates the task has failed TaskFailed TaskState = "failed" )
type Toleration ¶
type Toleration struct {
Key string
Value string
Effect TaintEffect
}
Toleration represents a toleration for a taint
type ZoneConstraint ¶
type ZoneConstraint struct {
Zone string
}
ZoneConstraint is a constraint that requires a specific zone
func (*ZoneConstraint) Satisfied ¶
func (c *ZoneConstraint) Satisfied(node *EnhancedNode) bool
Satisfied checks if the node satisfies the zone constraint