strategy

package
v0.0.0-...-06bcc1c Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Auto .
	Auto = "AUTO"
	// Fill .
	Fill = "FILL"
	// Each .
	Each = "EACH"
	// Global .
	Global = "GLOBAL"
	// Drained .
	Drained = "DRAINED"
	// Dummy for calculate capacity
	Dummy = "DUMMY"
)

Variables

Plans .

Functions

func AveragePlan

func AveragePlan(ctx context.Context, infos []Info, need, _, limit int) (map[string]int, error)

AveragePlan deploy workload each node 容量够的机器每一台部署 N 个 need 是每台机器所需总量,limit 是限制节点数, 保证本轮增量部署 need*limit 个实例 limit = 0 即对所有节点部署

func CommunismPlan

func CommunismPlan(_ context.Context, infos []Info, need, total, limit int) (map[string]int, error)

CommunismPlan 吃我一记共产主义大锅饭 部署完 N 个后全局尽可能平均

func Deploy

func Deploy(ctx context.Context, strategy string, count, nodesLimit int, strategyInfos []Info, total int) (map[string]int, error)

Deploy .

func DrainedPlan

func DrainedPlan(_ context.Context, infos []Info, need, total, _ int) (map[string]int, error)

DrainedPlan 优先往Capacity最小的节点部署,尽可能把节点的资源榨干在部署下一台.

func FillPlan

func FillPlan(ctx context.Context, infos []Info, need, _, limit int) (_ map[string]int, err error)

FillPlan deploy workload each node 根据之前部署的策略每一台补充到 N 个,已经超过 N 个的节点视为已满足 need 是每台上限, limit 是限制节点数, 保证最终状态至少有 limit*need 个实例 limit = 0 代表对所有节点进行填充

func GlobalPlan

func GlobalPlan(ctx context.Context, infos []Info, need, total, _ int) (map[string]int, error)

GlobalPlan 基于全局资源配额 尽量使得资源消耗平均

Types

type Info

type Info struct {
	Nodename string

	Usage float64
	Rate  float64

	Capacity int
	Count    int
}

Info .

Jump to

Keyboard shortcuts

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