How to define a ResourceQuota?

To define a ResourceQuota in Kubernetes, you can create a YAML manifest file that specifies the desired resource limits. Here’s an example of how to define a ResourceQuota that limits CPU and memory usage in a namespace:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: example-resourcequota
  namespace: your-namespace
spec:
  hard:
    requests.cpu: "1"        # Total CPU requests allowed
    requests.memory: "1Gi"    # Total memory requests allowed
    limits.cpu: "2"           # Total CPU limits allowed
    limits.memory: "2Gi"      # Total memory limits allowed

In this example:

  • Replace your-namespace with the name of the namespace where you want to apply the ResourceQuota.
  • The hard field specifies the maximum resources that can be requested or limited by all pods in the namespace.

To apply this ResourceQuota, save the YAML to a file (e.g., resourcequota.yaml) and run the following command:

kubectl apply -f resourcequota.yaml

This will create the ResourceQuota in the specified namespace, enforcing the defined resource limits.

0 Comments

no data
Be the first to share your comment!