Documentation ¶
Index ¶
- func Add(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList
- func CalculateUsage(namespaceName string, scopes []corev1.ResourceQuotaScope, ...) (corev1.ResourceList, error)
- func Contains(items []corev1.ResourceName, item corev1.ResourceName) bool
- func ContainsPrefix(prefixSet []string, item corev1.ResourceName) bool
- func Difference(a []corev1.ResourceName, b []corev1.ResourceName) []corev1.ResourceName
- func Equals(a corev1.ResourceList, b corev1.ResourceList) bool
- func Intersection(a []corev1.ResourceName, b []corev1.ResourceName) []corev1.ResourceName
- func IsNegative(a corev1.ResourceList) []corev1.ResourceName
- func IsZero(a corev1.ResourceList) bool
- func LessThanOrEqual(a corev1.ResourceList, b corev1.ResourceList) (bool, []corev1.ResourceName)
- func Mask(resources corev1.ResourceList, names []corev1.ResourceName) corev1.ResourceList
- func Max(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList
- func RemoveZeros(a corev1.ResourceList) corev1.ResourceList
- func ResourceNames(resources corev1.ResourceList) []corev1.ResourceName
- func Subtract(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList
- func SubtractWithNonNegativeResult(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList
- func ToSet(resourceNames []corev1.ResourceName) sets.String
- type Configuration
- type Evaluator
- type ListerForResourceFunc
- type Registry
- type UsageStats
- type UsageStatsOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList
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. If an error is returned, usage only contains the resources which encountered no calculation errors.
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 Difference ¶
func Difference(a []corev1.ResourceName, b []corev1.ResourceName) []corev1.ResourceName
Difference returns the list of resources resulting from a-b, deduped and sorted
func Equals ¶
func Equals(a corev1.ResourceList, b corev1.ResourceList) bool
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, deduped and sorted
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 ¶
func Max(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList
Max returns the result of Max(a, b) for each named resource
func RemoveZeros ¶ added in v0.20.2
func RemoveZeros(a corev1.ResourceList) corev1.ResourceList
RemoveZeros returns a new resource list that only has no zero values
func ResourceNames ¶
func ResourceNames(resources corev1.ResourceList) []corev1.ResourceName
ResourceNames returns a list of all resource names in the ResourceList
func Subtract ¶
func Subtract(a corev1.ResourceList, b corev1.ResourceList) corev1.ResourceList
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.
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