// IScheduler exports all scheduler public methods
type IScheduler interface {
// ScheduleWorkload returns a node selected from the chosen algorithm to bind the workload
ScheduleWorkload(workload *algorithms.Workload) (*nodes.Node, error)
// AddNode inserts new possible Node in the algorithm
AddNode(node *nodes.Node)
// UpdateNode replaces Node information in the algorithm
UpdateNode(oldNode *nodes.Node, newNode *nodes.Node)
// DeleteNode removes Node from the algorithm
DeleteNode(node *nodes.Node)
}
// Node represents a cluster Node
type Node struct {
// Name represents Node unique identifying name
Name string
// Labels represents all of Node labels
Labels map[string]string
// CPU represents Node available CPU resources in MilliValue
CPU int64
// Memory represents Node available Memory resources in MilliValue
Memory int64
}
Nodes can be configured with the following labels:
- node.geolocate.io - Node must have this label to be used in the algorithm
- node.geolocate.io/city - Indicates node city location
- node.geolocate.io/country - Indicates node country location
- node.geolocate.io/continent - Indicates node continent location
// Workload represents a cluster application to be scheduled
type Workload struct {
// Name represents Workload unique identifying name
Name string
// Labels represents all labels Node must have to be considered for this workload schedule
Labels map[string]string
// CPU represents Workloads' necessary CPU resources Nodes must at least have available
CPU int64
// Memory represents Workloads' necessary Memory resources Nodes must at least have available
Memory int64
}
Workloads can be configured with the following labels:
- workload.geolocate.io/requiredLocation - List of Workload required locations
- workload.geolocate.io/preferredLocation - List of Workload preferred locations
Location format:
(<CITY>?(_<CITY>)*)-(<COUNTRY>?(_<COUNTRY>)*))-(<CONTINENT>?(_<CONTINENT>)*))
Examples:
<CITY_A>-<COUNTRY_A>_<COUNTRY_B>-<CONTINENT_A>
-> Braga-Portugal_Spain-Europe
<CITY_A>_<CITY_B>--<CONTINENT_A>
-> Braga_Porto--Europe
go install github.com/golangci/golangci-lint/cmd/[email protected]
golangci-lint ./...
go test --coverprofile=coverage.out ./...
go tool cover -html=coverage.out
go fmt ./...