# Configure a Pod Quota for a Namespace

Configure a Pod Quota for a NamespaceRestrict how many Pods you can create within a namespace.This page shows how to set a quota for the total number of Pods that can run in a Namespace. You specify quotas in a ResourceQuota object.Before you beginYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesYou must have access to create namespaces in your cluster.Create a namespaceCreate a namespace so that the resources you create in this exercise are isolated from the rest of your cluster.kubectl create namespace quota-pod-example Create a ResourceQuotaHere is an example manifest for a ResourceQuota:admin/resource/quota-pod.yaml apiVersion: v1 kind: ResourceQuota metadata: name: pod-demo spec: hard: pods: "2" Create the ResourceQuota:kubectl apply -f https://k8s.io/examples/admin/resource/quota-pod.yaml --namespace=quota-pod-example View detailed information about the ResourceQuota:kubectl get resourcequota pod-demo --namespace=quota-pod-example --output=yaml The output shows that the namespace has a quota of two Pods, and that currently there are no Pods; that is, none of the quota is used.spec: hard: pods: "2" status: hard: pods: "2" used: pods: "0" Here is an example manifest for a Deployment:admin/resource/quota-pod-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: pod-quota-demo spec: selector: matchLabels: purpose: quota-demo replicas: 3 template: metadata: labels: purpose: quota-demo spec: containers: - name: pod-quota-demo image: nginx In that manifest, replicas: 3 tells Kubernetes to attempt to create three new Pods, all running the same application.Create the Deployment:kubectl apply -f https://k8s.io/examples/admin/resource/quota-pod-deployment.yaml --namespace=quota-pod-example View detailed information about the Deployment:kubectl get deployment pod-quota-demo --namespace=quota-pod-example --output=yaml The output shows that even though the Deployment specifies three replicas, only two Pods were created because of the quota you defined earlier:spec: ... replicas: 3 ... status: availableReplicas: 2 ... lastUpdateTime: 2021-04-02T20:57:05Z message: 'unable to create pods: pods "pod-quota-demo-1650323038-" is forbidden: exceeded quota: pod-demo, requested: pods=1, used: pods=2, limited: pods=2' Choice of resourceIn this task you have defined a ResourceQuota that limited the total number of Pods, but you could also limit the total number of other kinds of object. For example, you might decide to limit how many CronJobs that can live in a single namespace.Clean upDelete your namespace:kubectl delete namespace quota-pod-example What's nextFor cluster administratorsConfigure Default Memory Requests and Limits for a NamespaceConfigure Default CPU Requests and Limits for a NamespaceConfigure Minimum and Maximum Memory Constraints for a NamespaceConfigure Minimum and Maximum CPU Constraints for a NamespaceConfigure Memory and CPU Quotas for a NamespaceConfigure Quotas for API ObjectsFor app developersAssign Memory Resources to Containers and PodsAssign CPU Resources to Containers and PodsAssign Pod-level CPU and memory resourcesConfigure Quality of Service for Pods