Documentation ¶
Index ¶
- Constants
- Variables
- func ButResourcePoolMachineTypes(pool *poolV1.ResourcePoolConfig, machineTypes []string) *poolV1.ResourcePoolConfig
- func ButResourcePoolName(pool *poolV1.ResourcePoolConfig, name string) *poolV1.ResourcePoolConfig
- func ButResourceShapeLabels(pool *poolV1.ResourcePoolConfig, pairs ...string) *poolV1.ResourcePoolConfig
- func ComputeAllocatableCapacity(scheduledPods map[string]*v1.Pod, nodes map[string]*v1.Node, ...) (scaler.ComputeResource, scaler.ComputeResource, ...)
- func ComputeAllocatableCapacityFromSnapshot(snapshot *ResourceSnapshot, minimumResources scaler.ComputeResource, ...) (scaler.ComputeResource, scaler.ComputeResource, ...)
- func FormatResourcePool(resourcePool *poolV1.ResourcePoolConfig, options poolUtil.FormatterOptions) string
- func GetResourcePoolMachineTypes(resourcePool *poolV1.ResourcePoolConfig) []string
- func GroupNodesAndPods(resourcePool *poolV1.ResourcePoolSpec, allPods []*coreV1.Pod, ...) (map[string]poolUtil.NodeAndPods, []*coreV1.Pod)
- func GroupNodesByLifecycleState(nodes []*coreV1.Node, now time.Time, nodeBootstrapThreshold time.Duration) ([]*coreV1.Node, []*coreV1.Node, []*coreV1.Node)
- func NewResourcePoolCrdOf(name string, shapeDimensions poolV1.ComputeResource, shapeCount int64) *poolV1.ResourcePoolConfig
- func NewResourcePoolCrdOfMachine(name string, machineTypeConfig *machineTypeV1.MachineTypeConfig, ...) *poolV1.ResourcePoolConfig
- type ResourceSnapshot
- func (snapshot *ResourceSnapshot) ActiveCapacity() poolV1.ComputeResource
- func (snapshot *ResourceSnapshot) ActiveNodeCount() int64
- func (snapshot *ResourceSnapshot) AdjustResourcePoolSize(resourceCount int64) error
- func (snapshot *ResourceSnapshot) DumpSnapshotToLog(log logr.Logger, options poolUtil.FormatterOptions, withNodes bool, ...)
- func (snapshot *ResourceSnapshot) FormatResourceSnapshot(options poolUtil.FormatterOptions) string
- func (snapshot *ResourceSnapshot) NotProvisionedCapacity() poolV1.ComputeResource
- func (snapshot *ResourceSnapshot) NotProvisionedCount() int64
- func (snapshot *ResourceSnapshot) OnWayOutCapacity() poolV1.ComputeResource
- func (snapshot *ResourceSnapshot) OnWayOutNodeCount() int64
- func (snapshot *ResourceSnapshot) ReloadMachines() error
- func (snapshot *ResourceSnapshot) ReloadNodes() error
- func (snapshot *ResourceSnapshot) ReloadPods() error
- func (snapshot *ResourceSnapshot) ReloadResourcePool() error
- func (snapshot *ResourceSnapshot) UpdateNode(nodeID string, transformer func(*k8sCore.Node)) error
Constants ¶
const ( PoolNameEmpty = "emptyResourcePool" PoolNameIntegration = "integrationTestResourcePool" PoolNameIntegration2 = "integrationTestResourcePool2" )
const ( // Optional resource pool shape attribute specifying which machine types are used by it. // The value is a comma separated list of machine ids. ResourceShapeLabelMachineTypes = "machineTypes" )
Variables ¶
var ( EmptyResourcePool = func() *poolV1.ResourcePoolConfig { return &poolV1.ResourcePoolConfig{ ObjectMeta: metaV1.ObjectMeta{ Name: PoolNameEmpty, }, Spec: poolV1.ResourcePoolSpec{ Name: PoolNameEmpty, }, } } BasicResourcePool = func(name string, instanceCount int64, shape poolV1.ComputeResource) *poolV1.ResourcePoolConfig { pool := ButResourcePoolName(EmptyResourcePool(), name) pool.Spec.ResourceShape = poolV1.ResourceShape{ ComputeResource: shape, Labels: map[string]string{}, } pool.Spec.ResourceCount = instanceCount return pool } )
We use functions, as K8S records are mutable
Functions ¶
func ButResourcePoolMachineTypes ¶ added in v0.2.0
func ButResourcePoolMachineTypes(pool *poolV1.ResourcePoolConfig, machineTypes []string) *poolV1.ResourcePoolConfig
func ButResourcePoolName ¶ added in v0.7.0
func ButResourcePoolName(pool *poolV1.ResourcePoolConfig, name string) *poolV1.ResourcePoolConfig
func ButResourceShapeLabels ¶ added in v0.2.0
func ButResourceShapeLabels(pool *poolV1.ResourcePoolConfig, pairs ...string) *poolV1.ResourcePoolConfig
func ComputeAllocatableCapacity ¶ added in v0.9.0
func ComputeAllocatableCapacity(scheduledPods map[string]*v1.Pod, nodes map[string]*v1.Node, minimumResources scaler.ComputeResource, adjust bool, excludePreemptiblePods bool) ( scaler.ComputeResource, scaler.ComputeResource, map[string]scaler.ComputeResource)
ComputeAllocatableCapacity returns available capacity for every node in the given input. Second return value is actual available capacity per node without taking any DRF adjustment into account. It gives an upper bound on the available capacity that may be used to evaluate reservation shortage. The third return value is a map that contains actual remaining capacity per node without taking any DRF resource adjustment or minimum resource size check for debugging purposes. The fourth argument controls whether any preemptible pods running on the nodes should be excluded from the capacity usage and hence the capacity occupied by such pods should be considered available.
func ComputeAllocatableCapacityFromSnapshot ¶ added in v0.9.0
func ComputeAllocatableCapacityFromSnapshot(snapshot *ResourceSnapshot, minimumResources scaler.ComputeResource, adjust bool, excludePreemptiblePods bool) ( scaler.ComputeResource, scaler.ComputeResource, map[string]scaler.ComputeResource)
func FormatResourcePool ¶ added in v0.8.0
func FormatResourcePool(resourcePool *poolV1.ResourcePoolConfig, options poolUtil.FormatterOptions) string
func GetResourcePoolMachineTypes ¶ added in v0.2.0
func GetResourcePoolMachineTypes(resourcePool *poolV1.ResourcePoolConfig) []string
Machine types used by a resource pool or empty array if none is defined.
func GroupNodesAndPods ¶ added in v0.8.0
func GroupNodesAndPods(resourcePool *poolV1.ResourcePoolSpec, allPods []*coreV1.Pod, allNodes []*coreV1.Node) (map[string]poolUtil.NodeAndPods, []*coreV1.Pod)
For a given resource pool: 1. find its all nodes and pods 2. map pods to their nodes 3. collect pods not running on any node in a separate list
func GroupNodesByLifecycleState ¶ added in v0.9.0
func NewResourcePoolCrdOf ¶ added in v0.8.0
func NewResourcePoolCrdOf(name string, shapeDimensions poolV1.ComputeResource, shapeCount int64) *poolV1.ResourcePoolConfig
func NewResourcePoolCrdOfMachine ¶ added in v0.8.0
func NewResourcePoolCrdOfMachine(name string, machineTypeConfig *machineTypeV1.MachineTypeConfig, partsCount int64, shapeCount int64) *poolV1.ResourcePoolConfig
Types ¶
type ResourceSnapshot ¶
type ResourceSnapshot struct { ResourcePoolName string NodeBootstrapThreshold time.Duration PodYoungThreshold time.Duration IncludeKubeletBackend bool // State ResourcePool *poolV1.ResourcePoolConfig Machines []*machineTypeV1.MachineTypeConfig MachinesByName map[string]*machineTypeV1.MachineTypeConfig NodeSnapshot *poolNode.Snapshot PodSnapshot *poolPod.Snapshot // contains filtered or unexported fields }
Data structure that holds resource pool CRD and nodes and pods associated with this resource pool.
func NewResourceSnapshot ¶
func NewResourceSnapshot(client ctrlClient.Client, resourcePoolName string, nodeBootstrapThreshold time.Duration, includeKubeletBackend bool, withPods bool) (*ResourceSnapshot, error)
func NewStaticResourceSnapshot ¶ added in v0.2.0
func NewStaticResourceSnapshot(resourcePool *poolV1.ResourcePoolConfig, machines []*machineTypeV1.MachineTypeConfig, nodes []*k8sCore.Node, pods []*k8sCore.Pod, nodeBootstrapThreshold time.Duration, podYoungThreshold time.Duration, includeKubeletBackend bool) *ResourceSnapshot
New resource snapshot that is statically configured. Reloading functions when called do nothing.
func NewStaticResourceSnapshot2 ¶ added in v0.13.0
func NewStaticResourceSnapshot2(resourcePool *poolV1.ResourcePoolConfig, machines []*machineTypeV1.MachineTypeConfig, nodeSnapshot *poolNode.Snapshot, podSnapshot *poolPod.Snapshot, nodeBootstrapThreshold time.Duration, podYoungThreshold time.Duration, includeKubeletBackend bool) *ResourceSnapshot
New resource snapshot that is statically configured. Reloading functions when called do nothing.
func (*ResourceSnapshot) ActiveCapacity ¶
func (snapshot *ResourceSnapshot) ActiveCapacity() poolV1.ComputeResource
func (*ResourceSnapshot) ActiveNodeCount ¶
func (snapshot *ResourceSnapshot) ActiveNodeCount() int64
func (*ResourceSnapshot) AdjustResourcePoolSize ¶
func (snapshot *ResourceSnapshot) AdjustResourcePoolSize(resourceCount int64) error
func (*ResourceSnapshot) DumpSnapshotToLog ¶
func (snapshot *ResourceSnapshot) DumpSnapshotToLog(log logr.Logger, options poolUtil.FormatterOptions, withNodes bool, withPods bool)
func (*ResourceSnapshot) FormatResourceSnapshot ¶
func (snapshot *ResourceSnapshot) FormatResourceSnapshot(options poolUtil.FormatterOptions) string
func (*ResourceSnapshot) NotProvisionedCapacity ¶
func (snapshot *ResourceSnapshot) NotProvisionedCapacity() poolV1.ComputeResource
func (*ResourceSnapshot) NotProvisionedCount ¶
func (snapshot *ResourceSnapshot) NotProvisionedCount() int64
func (*ResourceSnapshot) OnWayOutCapacity ¶
func (snapshot *ResourceSnapshot) OnWayOutCapacity() poolV1.ComputeResource
Sum of resources of all nodes that are explicitly marked as decommissioned/removable.
func (*ResourceSnapshot) OnWayOutNodeCount ¶
func (snapshot *ResourceSnapshot) OnWayOutNodeCount() int64
func (*ResourceSnapshot) ReloadMachines ¶
func (snapshot *ResourceSnapshot) ReloadMachines() error
func (*ResourceSnapshot) ReloadNodes ¶
func (snapshot *ResourceSnapshot) ReloadNodes() error
func (*ResourceSnapshot) ReloadPods ¶
func (snapshot *ResourceSnapshot) ReloadPods() error
func (*ResourceSnapshot) ReloadResourcePool ¶
func (snapshot *ResourceSnapshot) ReloadResourcePool() error
func (*ResourceSnapshot) UpdateNode ¶
func (snapshot *ResourceSnapshot) UpdateNode(nodeID string, transformer func(*k8sCore.Node)) error