Modify ResourceQuota API to support requests/limits; scope filtering

This commit is contained in:
derekwaynecarr 2016-02-22 11:12:35 -05:00
parent 420d98fd8b
commit 55e3824272
2 changed files with 50 additions and 0 deletions

View File

@ -2189,12 +2189,37 @@ const (
ResourceSecrets ResourceName = "secrets" ResourceSecrets ResourceName = "secrets"
// ResourcePersistentVolumeClaims, number // ResourcePersistentVolumeClaims, number
ResourcePersistentVolumeClaims ResourceName = "persistentvolumeclaims" ResourcePersistentVolumeClaims ResourceName = "persistentvolumeclaims"
// CPU request, in cores. (500m = .5 cores)
ResourceRequestsCPU ResourceName = "requests.cpu"
// Memory request, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
ResourceRequestsMemory ResourceName = "requests.memory"
// CPU limit, in cores. (500m = .5 cores)
ResourceLimitsCPU ResourceName = "limits.cpu"
// Memory limit, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
ResourceLimitsMemory ResourceName = "limits.memory"
)
// A ResourceQuotaScope defines a filter that must match each object tracked by a quota
type ResourceQuotaScope string
const (
// Match all pod objects where spec.activeDeadlineSeconds
ResourceQuotaScopeTerminating ResourceQuotaScope = "Terminating"
// Match all pod objects where !spec.activeDeadlineSeconds
ResourceQuotaScopeNotTerminating ResourceQuotaScope = "NotTerminating"
// Match all pod objects that have best effort quality of service
ResourceQuotaScopeBestEffort ResourceQuotaScope = "BestEffort"
// Match all pod objects that do not have best effort quality of service
ResourceQuotaScopeNotBestEffort ResourceQuotaScope = "NotBestEffort"
) )
// ResourceQuotaSpec defines the desired hard limits to enforce for Quota // ResourceQuotaSpec defines the desired hard limits to enforce for Quota
type ResourceQuotaSpec struct { type ResourceQuotaSpec struct {
// Hard is the set of desired hard limits for each named resource // Hard is the set of desired hard limits for each named resource
Hard ResourceList `json:"hard,omitempty"` Hard ResourceList `json:"hard,omitempty"`
// A collection of filters that must match each object tracked by a quota.
// If not specified, the quota matches all objects.
Scopes []ResourceQuotaScope `json:"scopes,omitempty"`
} }
// ResourceQuotaStatus defines the enforced hard limits and observed use // ResourceQuotaStatus defines the enforced hard limits and observed use

View File

@ -2645,6 +2645,28 @@ const (
ResourceSecrets ResourceName = "secrets" ResourceSecrets ResourceName = "secrets"
// ResourcePersistentVolumeClaims, number // ResourcePersistentVolumeClaims, number
ResourcePersistentVolumeClaims ResourceName = "persistentvolumeclaims" ResourcePersistentVolumeClaims ResourceName = "persistentvolumeclaims"
// CPU request, in cores. (500m = .5 cores)
ResourceCPURequest ResourceName = "cpu.request"
// CPU limit, in cores. (500m = .5 cores)
ResourceCPULimit ResourceName = "cpu.limit"
// Memory request, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
ResourceMemoryRequest ResourceName = "memory.request"
// Memory limit, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
ResourceMemoryLimit ResourceName = "memory.limit"
)
// A ResourceQuotaScope defines a filter that must match each object tracked by a quota
type ResourceQuotaScope string
const (
// Match all pod objects where spec.activeDeadlineSeconds
ResourceQuotaScopeTerminating ResourceQuotaScope = "Terminating"
// Match all pod objects where !spec.activeDeadlineSeconds
ResourceQuotaScopeNotTerminating ResourceQuotaScope = "NotTerminating"
// Match all pod objects that have best effort quality of service
ResourceQuotaScopeBestEffort ResourceQuotaScope = "BestEffort"
// Match all pod objects that do not have best effort quality of service
ResourceQuotaScopeNotBestEffort ResourceQuotaScope = "NotBestEffort"
) )
// ResourceQuotaSpec defines the desired hard limits to enforce for Quota. // ResourceQuotaSpec defines the desired hard limits to enforce for Quota.
@ -2652,6 +2674,9 @@ type ResourceQuotaSpec struct {
// Hard is the set of desired hard limits for each named resource. // Hard is the set of desired hard limits for each named resource.
// More info: http://releases.k8s.io/HEAD/docs/design/admission_control_resource_quota.md#admissioncontrol-plugin-resourcequota // More info: http://releases.k8s.io/HEAD/docs/design/admission_control_resource_quota.md#admissioncontrol-plugin-resourcequota
Hard ResourceList `json:"hard,omitempty"` Hard ResourceList `json:"hard,omitempty"`
// A collection of filters that must match each object tracked by a quota.
// If not specified, the quota matches all objects.
Scopes []ResourceQuotaScope `json:"scopes,omitempty"`
} }
// ResourceQuotaStatus defines the enforced hard limits and observed use. // ResourceQuotaStatus defines the enforced hard limits and observed use.