Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PodStatus ¶
PodStatus represents the state of a Pod. It contains a pointer to a Pod object, a pointer to a Node object, and a boolean flag indicating whether the Pod has been deleted or not.
type Rebalancer ¶
type Rebalancer struct {
// contains filtered or unexported fields
}
Rebalancer represents a Rebalancer object.
func NewRebalancer ¶
func NewRebalancer(ctx context.Context, current *ReplicaState) *Rebalancer
NewRebalancer returns a new instance of the Rebalancer struct with the provided current replica state and a default maxRebalanceRate of 0.25. The Rebalancer struct contains methods for rebalancing pods across Nodes in a Kubernetes cluster.
func (*Rebalancer) Rebalance ¶
Rebalance rebalances the pods across the Nodes in the cluster. It returns a boolean indicating if any pods were rebalanced and an error, if any. The rebalancing is done by deleting pods from the Node that has the maximum number of pods until the Pod count on that Node is less than or equal to the average number of pods across all Nodes plus one. The maximum number of pods to be deleted is calculated based on the specified rebalance rate. If the number of Nodes is less than 2, the number of replicas is less than 2, or the current number of replicas is less than the specified replicas, no rebalancing is performed and the function returns false.
type ReplicaState ¶
type ReplicaState struct { Replicaset *appsv1.ReplicaSet Nodes []*corev1.Node PodStatus []*PodStatus }
ReplicaState represents the state of a replica set. It contains a pointer to a replica set object, an array of Nodes, and an array of Pod states.