quota

package
Version: v1.14.9 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

Add returns the result of a + b for each named resource

func CalculateUsage

func CalculateUsage(namespaceName string, scopes []corev1.ResourceQuotaScope, hardLimits corev1.ResourceList, registry Registry, scopeSelector *corev1.ScopeSelector) (corev1.ResourceList, error)

CalculateUsage calculates and returns the requested ResourceList usage

func Contains

func Contains(items []corev1.ResourceName, item corev1.ResourceName) bool

Contains returns true if the specified item is in the list of items

func ContainsPrefix

func ContainsPrefix(prefixSet []string, item corev1.ResourceName) bool

ContainsPrefix returns true if the specified item has a prefix that contained in given prefix Set

func Equals

Equals returns true if the two lists are equivalent

func Intersection

func Intersection(a []corev1.ResourceName, b []corev1.ResourceName) []corev1.ResourceName

Intersection returns the intersection of both list of resources

func IsNegative

func IsNegative(a corev1.ResourceList) []corev1.ResourceName

IsNegative returns the set of resource names that have a negative value.

func IsZero

func IsZero(a corev1.ResourceList) bool

IsZero returns true if each key maps to the quantity value 0

func LessThanOrEqual

func LessThanOrEqual(a corev1.ResourceList, b corev1.ResourceList) (bool, []corev1.ResourceName)

LessThanOrEqual returns true if a < b for each key in b If false, it returns the keys in a that exceeded b

func Mask

func Mask(resources corev1.ResourceList, names []corev1.ResourceName) corev1.ResourceList

Mask returns a new resource list that only has the values with the specified names

func Max

Max returns the result of Max(a, b) for each named resource

func ResourceNames

func ResourceNames(resources corev1.ResourceList) []corev1.ResourceName

ResourceNames returns a list of all resource names in the ResourceList

func Subtract

Subtract returns the result of a - b for each named resource

func SubtractWithNonNegativeResult

func SubtractWithNonNegativeResult(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList

SubtractWithNonNegativeResult - subtracts and returns result of a - b but makes sure we don't return negative values to prevent negative resource usage.

func ToSet

func ToSet(resourceNames []corev1.ResourceName) sets.String

ToSet takes a list of resource names and converts to a string set

func V1Equals

V1Equals returns true if the two lists are equivalent

Types

type Configuration

type Configuration interface {
	// IgnoredResources are ignored by quota.
	IgnoredResources() map[schema.GroupResource]struct{}
	// Evaluators for quota evaluation.
	Evaluators() []Evaluator
}

Configuration defines how the quota system is configured.

type Evaluator

type Evaluator interface {
	// Constraints ensures that each required resource is present on item
	Constraints(required []corev1.ResourceName, item runtime.Object) error
	// GroupResource returns the groupResource that this object knows how to evaluate
	GroupResource() schema.GroupResource
	// Handles determines if quota could be impacted by the specified attribute.
	// If true, admission control must perform quota processing for the operation, otherwise it is safe to ignore quota.
	Handles(operation admission.Attributes) bool
	// Matches returns true if the specified quota matches the input item
	Matches(resourceQuota *corev1.ResourceQuota, item runtime.Object) (bool, error)
	// MatchingScopes takes the input specified list of scopes and input object and returns the set of scopes that matches input object.
	MatchingScopes(item runtime.Object, scopes []corev1.ScopedResourceSelectorRequirement) ([]corev1.ScopedResourceSelectorRequirement, error)
	// UncoveredQuotaScopes takes the input matched scopes which are limited by configuration and the matched quota scopes. It returns the scopes which are in limited scopes but dont have a corresponding covering quota scope
	UncoveredQuotaScopes(limitedScopes []corev1.ScopedResourceSelectorRequirement, matchedQuotaScopes []corev1.ScopedResourceSelectorRequirement) ([]corev1.ScopedResourceSelectorRequirement, error)
	// MatchingResources takes the input specified list of resources and returns the set of resources evaluator matches.
	MatchingResources(input []corev1.ResourceName) []corev1.ResourceName
	// Usage returns the resource usage for the specified object
	Usage(item runtime.Object) (corev1.ResourceList, error)
	// UsageStats calculates latest observed usage stats for all objects
	UsageStats(options UsageStatsOptions) (UsageStats, error)
}

Evaluator knows how to evaluate quota usage for a particular group resource

type ListerForResourceFunc

type ListerForResourceFunc func(schema.GroupVersionResource) (cache.GenericLister, error)

ListerForResourceFunc knows how to get a lister for a specific resource

type Registry

type Registry interface {
	// Add to registry
	Add(e Evaluator)
	// Remove from registry
	Remove(e Evaluator)
	// Get by group resource
	Get(gr schema.GroupResource) Evaluator
	// List from registry
	List() []Evaluator
}

Registry maintains a list of evaluators

type UsageStats

type UsageStats struct {
	// Used maps resource to quantity used
	Used corev1.ResourceList
}

UsageStats is result of measuring observed resource use in the system

type UsageStatsOptions

type UsageStatsOptions struct {
	// Namespace where stats should be calculate
	Namespace string
	// Scopes that must match counted objects
	Scopes []corev1.ResourceQuotaScope
	// Resources are the set of resources to include in the measurement
	Resources     []corev1.ResourceName
	ScopeSelector *corev1.ScopeSelector
}

UsageStatsOptions is an options structs that describes how stats should be calculated

Directories

Path Synopsis
evaluator
core
core contains modules that interface with the core api group
core contains modules that interface with the core api group

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL