Documentation
¶
Index ¶
- Constants
- func ConvertFromCoreV1ResourceList(resourceList corev1.ResourceList) map[string]apiresource.Quantity
- func ConvertToCoreV1ResourceList(resourceList map[string]apiresource.Quantity) corev1.ResourceList
- func IsExtendedResourceName(name Name) bool
- func IsIntegerResourceName(str string) bool
- func IsNativeResource(name Name) bool
- func IsQuotaHugePageResourceName(name Name) bool
- func IsStandardQuotaResourceName(str string) bool
- func IsStandardResourceName(str string) bool
- func ValidateAllocatableResources(wantAllocate business.ResourceList, hasAllocated business.ResourceList, ...) field.ErrorList
- func ValidateNonnegativeQuantity(value resource.Quantity, fldPath *field.Path) field.ErrorList
- func ValidateResourceQuantityValue(resource string, value resource.Quantity, fldPath *field.Path) field.ErrorList
- func ValidateResourceQuotaResourceName(value string, fldPath *field.Path) field.ErrorList
- func ValidateUpdateResource(hard business.ResourceList, used business.ResourceList, fldPath *field.Path) field.ErrorList
- type Name
Constants ¶
const ( QuotaLimitErrorInfo = "must set quota" AllocatableErrorInfo = "should NOT be more than remaining quantity" UpdateQuotaErrorInfo = "should NOT be less than used quantity" )
const ( // DefaultNamespacePrefix namespace prefix. DefaultNamespacePrefix = "kubernetes.io/" // HugePagesPrefix is huge pages prefix. HugePagesPrefix = "hugepages-" )
const ( // RequestsHugePagesPrefix request, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) // As burst is not supported for HugePages, we would only quota its request, and ignore the limit. RequestsHugePagesPrefix = "requests.hugepages-" // Default resource requests prefix DefaultResourceRequestsPrefix = "requests." )
The following identify resource prefix for Kubernetes object types
Variables ¶
This section is empty.
Functions ¶
func ConvertFromCoreV1ResourceList ¶
func ConvertFromCoreV1ResourceList(resourceList corev1.ResourceList) map[string]apiresource.Quantity
ConvertFromCoreV1ResourceList convert the kubernetes core resource list to common resource list.
func ConvertToCoreV1ResourceList ¶
func ConvertToCoreV1ResourceList(resourceList map[string]apiresource.Quantity) corev1.ResourceList
ConvertToCoreV1ResourceList convert the resource list in tke to kubernetes core resource list.
func IsExtendedResourceName ¶
IsExtendedResourceName returns true if: 1. the resource name is not in the default namespace; 2. resource name does not have "requests." prefix, to avoid confusion with the convention in quota 3. it satisfies the rules in IsQualifiedName() after converted into quota resource name
func IsIntegerResourceName ¶
IsIntegerResourceName returns true if the resource is measured in integer values
func IsNativeResource ¶
IsNativeResource returns true if the resource name is in the *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are implicitly in the kubernetes.io/ namespace.
func IsQuotaHugePageResourceName ¶
IsQuotaHugePageResourceName returns true if the resource name has the quota related huge page resource prefix.
func IsStandardQuotaResourceName ¶
IsStandardQuotaResourceName returns true if the resource is known to the quota tracking system
func IsStandardResourceName ¶
IsStandardResourceName returns true if the resource is known to the system
func ValidateAllocatableResources ¶
func ValidateAllocatableResources(wantAllocate business.ResourceList, hasAllocated business.ResourceList, capacity business.ResourceList, used business.ResourceList, fldPath *field.Path) field.ErrorList
ValidateAllocatableResources is used to verify whether the resource quota to be allocated meets the total resource quota minus the condition of the used resource.
func ValidateNonnegativeQuantity ¶
ValidateNonnegativeQuantity that a Quantity is not negative
func ValidateResourceQuantityValue ¶
func ValidateResourceQuantityValue(resource string, value resource.Quantity, fldPath *field.Path) field.ErrorList
ValidateResourceQuantityValue enforces that specified quantity is valid for specified resource
func ValidateResourceQuotaResourceName ¶
ValidateResourceQuotaResourceName resource names that can go in a resource quota Refer to docs/design/resources.md for more details.
func ValidateUpdateResource ¶
func ValidateUpdateResource(hard business.ResourceList, used business.ResourceList, fldPath *field.Path) field.ErrorList
ValidateUpdateResource is used to verify that the adjusted quota when updating the resource quota cannot be less than the used one.
Types ¶
type Name ¶
type Name string
Name is the name identifying various resources in a ResourceList.
const ( // CPU, in cores. (500m = .5 cores) CPU Name = "cpu" // Memory, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) Memory Name = "memory" // Volume size, in bytes (e,g. 5Gi = 5GiB = 5 * 1024 * 1024 * 1024) Storage Name = "storage" // Local ephemeral storage, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) // The resource name for EphemeralStorage is alpha and it can change across releases. EphemeralStorage Name = "ephemeral-storage" )
Resource names must be not more than 63 characters, consisting of upper- or lower-case alphanumeric characters, with the -, _, and . characters allowed anywhere, except the first or last character. The default convention, matching that for annotations, is to use lower-case names, with dashes, rather than camel case, separating compound words. Fully-qualified resource typenames are constructed from a DNS-style subdomain, followed by a slash `/` and a name.
const ( // Pods, number Pods Name = "pods" // Services, number Services Name = "services" // ReplicationControllers, number ReplicationControllers Name = "replicationcontrollers" // Quotas, number Quotas Name = "resourcequotas" // Secrets, number Secrets Name = "secrets" // ConfigMaps, number ConfigMaps Name = "configmaps" // PersistentVolumeClaims, number PersistentVolumeClaims Name = "persistentvolumeclaims" // ServicesNodePorts, number ServicesNodePorts Name = "services.nodeports" // ServicesLoadBalancers, number ServicesLoadBalancers Name = "services.loadbalancers" // CPU request, in cores. (500m = .5 cores) RequestsCPU Name = "requests.cpu" // Memory request, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) RequestsMemory Name = "requests.memory" // Storage request, in bytes RequestsStorage Name = "requests.storage" // Local ephemeral storage request, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) RequestsEphemeralStorage Name = "requests.ephemeral-storage" // CPU limit, in cores. (500m = .5 cores) LimitsCPU Name = "limits.cpu" // Memory limit, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) LimitsMemory Name = "limits.memory" // Local ephemeral storage limit, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) LimitsEphemeralStorage Name = "limits.ephemeral-storage" )
The following identify resource constants for Kubernetes object types