utils

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControllerName = "kotary-controller"

	SharedInformerNotSync = "%s shared informer not synced"

	MessageRejectedMemory = "Not enough Memory claiming %s but %s currently available"
	MessageRejectedCPU    = "Not enough CPU claiming %s but %s currently available"

	MessageMemoryAllocationLimit = "Exceeded Memory allocation limit claiming %s but limited to %s"
	MessageCpuAllocationLimit    = "Exceeded CPU allocation limit claiming %s but limited to %s"

	MessagePendingMemoryDownscale = "Awaiting lower Memory consumption claiming %s but current total of request is %s"
	MessagePendingCpuDownscale    = "Awaiting lower CPU consumption claiming %s but current total of CPU request is %s"

	ResourceQuotaName = "managed-quota"

	EmptyMsg = ""
)

Variables

View Source
var ClaimCounter = promauto.NewCounterVec(prometheus.CounterOpts{
	Name: "rq_operator_claims",
	Help: "Number of claims",
}, []string{"status"})
View Source
var DefaultClaimCounter = promauto.NewCounterVec(prometheus.CounterOpts{
	Name: "rq_operator_default_claims",
	Help: "Number of default claims created",
}, []string{"status"})

Functions

func BytesSize

func BytesSize(size float64) string

func CustomSize

func CustomSize(format string, size float64, base float64, _map []string) string

func DefaultDeleteOptions

func DefaultDeleteOptions() *metav1.DeleteOptions

func DefaultLabelSelector

func DefaultLabelSelector() (selector labels.Selector)

func FilterNodesWithPredicate added in v1.24.0

func FilterNodesWithPredicate(ss []*v1.Node, test func(*v1.Node) bool) (ret []*v1.Node)

func FilterRunningPods added in v1.24.0

func FilterRunningPods(pods []*v1.Pod) []*v1.Pod

func FilterWorkerNode

func FilterWorkerNode() func(*v1.Node) bool

Predicate to filter out un-schedulable, role master labeled or not ready nodes

func MapIntersects

func MapIntersects(a map[string]string, b map[string]string) bool

Maps a and b have intersection

func NodesCpuAllocatable

func NodesCpuAllocatable(workerNodes []*v1.Node) (result int64)

func NodesMemAllocatable

func NodesMemAllocatable(workerNodes []*v1.Node) (result int64)

func PodsCpuRequest

func PodsCpuRequest(pods []*v1.Pod) (result int64)

func PodsMemRequest

func PodsMemRequest(pods []*v1.Pod) (result int64)

func TotalRequestNS

func TotalRequestNS(pods []*v1.Pod) *v1.ResourceList

Types

type Config

type Config struct {

	// The spec of the default ResourceQuotaClaim to apply on Namespaces
	DefaultClaimSpec v1.ResourceList `yaml:"defaultClaimSpec"`

	// Maximum resource size that can be claimed compared to the total cluster size
	// 0.3 -> Max claim size will be a third of the cluster resources
	RatioMaxAllocationMemory float64 `yaml:"ratioMaxAllocationMemory"`
	RatioMaxAllocationCPU    float64 `yaml:"ratioMaxAllocationCPU"`

	// Apply an over provisioning on the available resources of all the nodes
	// Represented as a percentage (could be under 100 to under provision)
	RatioOverCommitMemory float64 `yaml:"ratioOverCommitMemory"`
	RatioOverCommitCPU    float64 `yaml:"ratioOverCommitCPU"`
}

Hold the configurations specification

type ConfigurationManager

type ConfigurationManager struct {
	Conf Config
	// contains filtered or unexported fields
}

Hold the config and a clienset to retrieve it

func NewSettingManger

func NewSettingManger(clientset kubernetes.Interface) *ConfigurationManager

Create a new instance

func (*ConfigurationManager) Load

func (c *ConfigurationManager) Load()

Load configmap based on where the controller is running

Jump to

Keyboard shortcuts

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