planner

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Plan

func Plan(
	rsp *ReplicaSchedulingPreference,
	totalReplicas int64,
	availableClusters []string,
	currentReplicaCount map[string]int64,
	estimatedCapacity map[string]int64,
	limitedCapacity map[string]int64,
	replicaSetKey string,
	avoidDisruption bool,
	keepUnschedulableReplicas bool,
) (map[string]int64, map[string]int64, error)

Distribute the desired number of replicas among the given cluster according to the planner preferences. The function tries its best to assign each cluster the preferred number of replicas, however if sum of MinReplicas for all cluster is bigger than replicasToDistribute (TotalReplicas) then some cluster will not have all of the replicas assigned. In such case a cluster with higher weight has priority over cluster with lower weight (or with lexicographically smaller name in case of draw). It can also use the current replica count and estimated capacity to provide better planning and adhere to rebalance policy. To avoid prioritization of clusters with smaller lexicographical names a semi-random string (like replica set name) can be provided. Two maps are returned:

  • a map that contains information how many replicas will be possible to run in a cluster.
  • a map that contains information how many extra replicas would be nice to schedule in a cluster so, if by chance, they are scheduled we will be closer to the desired replicas layout.

NOTE: The planner's algorithm DOES NOT SUPPORT negative values, and it is the caller's responsibility to sanitize the corresponding arguments before passing them into this method.

Types

type ClusterPreferences

type ClusterPreferences struct {
	// Minimum number of replicas that should be assigned to this cluster workload object. 0 by default.
	MinReplicas int64

	// Maximum number of replicas that should be assigned to this cluster workload object.
	// Unbounded if no value provided (default).
	MaxReplicas *int64

	// A number expressing the preference to put an additional replica to this cluster workload object.
	// 0 by default.
	Weight int64
}

Preferences regarding number of replicas assigned to a cluster workload object (dep, rs, ..) within a federated workload object.

type ReplicaSchedulingPreference

type ReplicaSchedulingPreference struct {
	// A mapping between cluster names and preferences regarding a local workload object (dep, rs, .. ) in
	// these clusters.
	// "*" (if provided) applies to all clusters if an explicit mapping is not provided.
	// If omitted, clusters without explicit preferences should not have any replicas scheduled.
	Clusters map[string]ClusterPreferences
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL