Skip to main content
Version: 1.14.0

Manage Resource Quotas

Resource quotas enable the cluster admins to enforce limits for CPU, memory, ephemeral storage and number of application pods per namespace on a slice. It requires setting and monitoring the threshold limit and requests of the resources at the slice level.

The cluster admin can manage the usage of compute resources on a slice ensuring that the namespaces get a fair share of the resources. This prevents some namespaces from overusing the resources leaving little or no resources for other namespaces on the same slice.

Requests and limits are the ways Kubernetes uses to manage resources such as CPU and memory. Requests are what the container is assured to get. Limits ensure that a container is restricted to a particular value. You can also set quotas for requests and limits to manage the local ephemeral storage.

A default limit and request can be configured per container and their purpose is described below:

  • Default limit per container: This is used for a container in the namespace that does not have resource limits configured. The default limit per container is set at the namespace level.
  • Default request per container: This is used for a container in the namespace that does not have resource requests configured. A default request per container can be set at the slice quota that applies to all namespaces on the slice. This default request per container set at the slice level is overridden when it is set at the namespace level.

Enforce Resource Quota

The resource quota is enforced only at the namespace level but you can set quotas for the limits and requests for a slice. The CPU, memory, pod count, and the local ephemeral storage of all namespaces in a slice must be less than or equal to their corresponding limits and requests set for a slice. The admin can check for quota breaches by tracking the violation in usage metrics through PromQL queries and KubeSlice Manager.

While setting the limits and requests for resources, you should consider the application requirements and define the limit and request values. For more information, see quotas.

Resource Quota Configuration Parameters

The following tables describe the configuration parameters used to set quotas in the sliceResourceQuotaConfig YAML file.

ParameterParameter TypeDescriptionRequired
apiVersionStringThe KubeSlice Controller API version. A set of resources that are exposed together, along with the version. The value must be controller.kubeslice.io/v1alpha1.Mandatory
kindStringThe name of a particular object schema. The value must be SliceResourceQuotaConfig.Mandatory
metadataObjectThe metadata describes parameters (names and types) and attributes that have been applied.Mandatory
specObjectThe specification of the desired state of an object.Mandatory

Resource Quota Metadata Parameters

These parameters are related to setting quotas, which are configured in the sliceResourceQuotaConfig YAML file.

ParameterParameter TypeDescriptionRequired
nameStringThe name of the slice resource quota.Mandatory

Resource Quota Spec Parameters

These parameters are related to the setting quotas, which are configured in the sliceResourceQuotaConfig YAML file.

ParameterParameter TypeDescriptionRequired
sliceQuotaObjectIt contains the resources for which the total limits that can be consumed by the namespaces on this slice. The total limits are configured at a slice level.Optional
clusterQuotaObjectIt contains the name of the worker clusters, and the quotas set for the namespaces on a slice.Optional

sliceQuota Parameters

These parameters are related to setting the total number of quotas for a slice, which are configured in the sliceResourceQuotaConfig YAML file.

ParameterParameter TypeDescriptionRequired
resourcesObjectThe resources contains the limit and request objects that sets limits for CPU, memory, ephemeral storage and pod count (only apply to limits) for all namespaces on a slice.Optional
resources Parameters
ParameterParameter TypeDescriptionRequired
limitObjectIt is the quota object for the limits set for CPU, memory, ephemeral storage, and pod count for all namespaces on a slice.Optional
requestObjectIt is the quota object for the total requests set for CPU, memory, and ephemeral storage for all namespaces on a slice.Optional
defaultRequestPerContainerObjectIt is the quota object for the default requests per container set for CPU, memory, and ephemeral storage for all namespaces on a slice. For a resource type, the default request per container must be less than or equal to the corresponding request.Optional
limit Parameters
ParameterParameter TypeDescriptionRequired
cpuStringIt sets the CPU limit for all namespaces on a slice. Its value is in millicores and it does not accept negative values.Optional
memoryStringIt sets the total memory limit for all namespaces on a slice. Its value is in Mi and it does not accept negative values.Optional
podCountStringIt sets the limit for the total number of application pods on a slice.Optional
ephemeralStorageStringIt sets the total limit for the local ephemeral storage for all namespaces on a slice. Its value is in Mi and it does not accept negative values.Optional
request Parameters
ParameterParameter TypeDescriptionRequired
cpuStringIt sets the the CPU request total for all the namespaces on a slice. Its value is in millicores and it does not accept negative values. The value must be less than or equal to the CPU limit.Optional
memoryStringIt sets the memory request total for all the namespaces on a slice. Its value is in Mi and it does not accept negative values. The value must be less than or equal to the memory limit.Optional
ephemeralStorageStringIt sets the request for the total ephemeral storage for all the namespaces on a slice. The value must be less than or equal to the ephemeral storage limit.Optional
defaultRequestPerContainer Parameters
info

This default request per container value holds good to all namespaces. To override this value, you can set the same parameter under namespaceQuota.

ParameterParameter TypeDescriptionRequired
cpuStringIt sets the the default CPU request per container for all the pods of a namespace. Its value is in millicores and it does not accept negative values. The value must be less than or equal to the CPU request.Optional
memoryStringIt sets the default memory request per container for all the pods of a namespace. Its value is in Mi and it does not accept negative values. The value must be less than or equal to the memory request.Optional
ephemeralStorageStringIt sets the default request for the local ephemeral storage per container for all the pods of a namespace. Its value is in Mi and it does not accept negative values. The value must be less than or equal to the ephemeral storage request.Optional

clusterQuota Parameters

These parameters are related to enforcing the quotas on the namespaces on all the worker clusters connected to a slice. They are configured in the
sliceResourceQuotaConfig YAML file.

ParameterParameter TypeDescriptionRequired
clusterNameStringIt is the name of the worker cluster that contains the namespaces onboarded onto the slice.Mandatory
namespaceQuotaObjectIt contains the configuration of the resources' limits set for all the application pods in the namespace.Optional

namespaceQuota Parameters

These parameters are related to the quotas enforced for a namespace, which are configured in the sliceResourceQuotaConfig YAML file.

ParameterParameter TypeDescriptionRequired
enforceQuotaBooleanWhen enabled, it enforces the quota limit at the namespace level. The value should be set to true.Mandatory
namespaceStringThe namespace on which you want to enforce the quota.Mandatory
resourcesObjectThe resources contains the limit object that sets limits for CPU, memory, ephemeral storage and pod count (only apply to limits).Optional

resources Parameters under namespaceQuota

ParameterParameter TypeDescriptionRequired
limitObjectIt is the quota object for limits set for CPU, memory, ephemeral storage, and pods count.Optional
requestObjectIt is the quota object for requests set for CPU, memory, and ephemeral storage.Optional
defaultLimitPerContainerObjectIt is the quota object for default limits per container set for CPU, memory, and ephemeral storage of a namespace.Optional
defaultRequestPerContainerObjectIt is the quota object for the default requests per container set for CPU, memory, and ephemeral storage of a namespace.Optional.

limit Parameters under nameSpaceQuota

ParameterParameter TypeDescriptionRequired
cpuStringIt sets the the CPU limit for all the pods of a namespace. Its value is in millicores and it does not accept negative values. The value must be less than less than or equal to the CPU limit set under sliceQuota. If you want to set the CPU limit for more than one namespace, then ensure that the total CPU limit of all the namespaces does not exceed the corresponding CPU limit set under sliceQuota.Optional
memoryStringIt sets the memory limit for all the pods of a namespace. Its value is in Mi and it does not accept negative values. The value must be less than or equal to the memory limit set under sliceQuota. If you want to set the memory limit for more than one namespace, then ensure that the total memory limit of all the namespaces does not exceed the corresponding memory limit set under sliceQuota.Optional
podCountStringIt sets the limit for the total number of application pods that can exist in a namespace. The value must be less than the pod count limit set under sliceQuota. If you want to set the pod count limit for more than one namespace, then ensure that the total pod count limit of all the namespaces does not exceed the corresponding pod count limit set under sliceQuota.Optional
ephemeralStorageStringIt sets the limit for the local ephemeral storage for all the pods of a namespace. Its value is Mi and it does not accept negative values. The value must be less than or equal to the ephemeral storage limit set under sliceQuota. If you want to set the ephemeral storage limit for more than one namespace, then ensure that the total ephemeral storage limit of all the namespaces does not exceed to the corresponding ephemeral storage limit set under sliceQuota.Optional

request Parameters under namespaceQuota

ParameterParameter TypeDescriptionRequired
cpuStringIt sets the the CPU request total for all the pods of the namespace. Its value is in millicores and it does not accept negative values. The value must be less than or equal to the CPU limit set for the namespace. If you want to set the CPU request for more than one namespace, then ensure that the total requests of all the namespaces does not exceed the corresponding request set under sliceQuota.Optional
memoryStringIt sets the memory request total for all the pods of the namespace. Its value is in Mi and it does not accept negative values. The value must be less than or equal to the memory limit set for the namespace. If you want to set the memory request for more than one namespace, then ensure that the total request of all the namespaces does not exceed the corresponding request set under sliceQuota.Optional
ephemeralStorageStringIt sets the request for local ephemeral storage for all pods of the namespace. Its value is in Mi and it does not accept negative values. The value must be less than or equal to the ephemeral storage request set for the namespace. If you want to set the ephemeral storage request for more than one namespace, then ensure that the total requests of all the namespaces does not exceed the corresponding request set under sliceQuota.Optional

defaultLimitPerContainer Parameters under namespaceQuota

ParameterParameter TypeDescriptionRequired
cpuStringIt sets the the default CPU limit per container for all the pods of a namespace. Its value is in millicores and it does not accept negative values. If the CPU limit is configured, then you must set the default CPU limit per container. This value must be less than or equal to the CPU limit set for the namespace.Optional
memoryStringIt sets the default memory limit per container for all the pods of a namespace. Its value is in Mi and it does not accept negative values. If the memory limit is configured, then you must set the default memory limit per container. This value must be less than or equal to the memory limit set for the namespace.Optional
ephemeralStorageStringIt sets the default local ephemeral storage limit per container for all the pods of a namespace. Its value is in Mi and it does not accept negative values. If the ephemeral storage limit is configured, then you must set the default ephemeral storage limit per container. This value must be less than or equal to the ephemeral storage limit set for the namespace.Optional

defaultRequestPerContainer Parameters under namespaceQuota

info

The defaultRequestPerContainer set at the namespace level overrides the corresponding value set under sliceQuota.

ParameterParameter TypeDescriptionRequired
cpuStringIt sets the the default CPU request per container for all the pods of a namespace. Its value is in millicores and it does not accept negative values. If this parameter is not set at the slice level, then you must set it at the namespace level. This value must be less than or equal to the default limit per container and the request set for the namespace.Optional
memoryStringIt sets the default memory request for all the pods of a namespace. Its value is in Mi and it does not accept negative values. If this parameter is not set at the slice level, then you must set it at the namespace level. This value must be less than or equal to the default limit per container and the request set for the namespace.Optional
ephemeralStorageStringIt sets the default ephemeral storage request for all the pods of the namespace. Its value is in Mi and it does not accept negative values. If this parameter is not set at the slice level, then you must set it at the namespace level. This value must be less than or equal to the default limit per container and the request set for the namespace.Optional

Configure Quotas

clusterQuota is used as an object that contains the names of the worker clusters and namespaces that are on them. The limits can be enforced on the namespaces that are within the cluster. The limits are not set at a cluster level.

Create Resource Quota YAML

Copy and save the below slice-resource-configuration.yaml template:

apiVersion: controller.kubeslice.io/v1alpha1
kind: SliceResourceQuotaConfig
metadata:
name: red
spec:
sliceQuota:
resources:
limit:
cpu: 1800m
memory: 1800Mi
podCount: 44
ephemeralStorage: 1300Mi
request:
cpu: 500m
memory: 500Mi
ephemeralStorage: 300Mi
defaultRequestPerContainer:
cpu: 14m
memory: 17Mi
ephemeralStorage: 12Mi
clusterQuota:
- clusterName: cluster-1
namespaceQuota:
- enforceQuota: true
namespace: namespace-1
resources:
limit:
cpu: 500m
memory: 500Mi
podCount: 5
ephemeralStorage: 300Mi
request:
cpu: 50m
memory: 18Mi
ephemeralStorage: 30Mi
defaultRequestPerContainer:
cpu: 4m
memory: 10Mi
ephemeralStorage: 10Mi
defaultLimitPerContainer:
cpu: 10m
memory: 20Mi
ephemeralStorage: 20Mi

Apply the Slice Quota Configuration

After creating the YAML file, apply it on the project namespace using the following command:

kubectl apply -f <slice-resource-configuration>.yaml -n <project namespace>

Validate the Slice Quota Configuration

Validate the slice quota configuration using the following command:

 kubectl get SliceResourceQuotaConfig -n <project namespace>

Example

 kubectl get SliceResourceQuotaConfig -n kubeslice-avesha

**** Expected Output****

NAME  AGE
red 10s

Edit Slice Quotas

You can edit quotas for limits and requests by:

  • Editing the slice-resource-configuration.yamlfile and applying the YAML file to refresh the configuration.

Delete Slice Quotas

You can delete the slice quotas for limits by running the following command to delete the slice quotas for limits and requests:

kubectl delete SliceResourceQuotaConfig <name of the slice resource quota> -n <project namespace>