2019-10-23 14:06:03 -07:00
# Configure namespace limits and quotas
2019-10-24 18:41:37 -05:00
To limit the number of resources like CPU and memory, as well as objects that may be consumed by workloads in a namespace, it is important to configure resource limits and quotas for each namespace.
2019-10-23 15:36:37 -07:00
## Additional Information
* [Resource Quota ](https://kubernetes.io/docs/concepts/policy/resource-quotas/ )
2019-10-23 14:06:03 -07:00
## Policy YAML
2019-11-10 20:58:57 -08:00
[add_ns_quota.yaml ](best_practices/add_ns_quota.yaml )
2019-10-23 14:06:03 -07:00
````yaml
2019-11-13 13:56:20 -08:00
apiVersion: kyverno.io/v1
2019-10-23 14:06:03 -07:00
kind: ClusterPolicy
metadata:
2019-11-10 20:58:57 -08:00
name: add-ns-quota
2019-10-23 14:06:03 -07:00
spec:
rules:
2019-11-10 20:58:57 -08:00
- name: generate-resourcequota
2019-10-23 14:06:03 -07:00
match:
resources:
kinds:
- Namespace
generate:
kind: ResourceQuota
2019-11-10 20:58:57 -08:00
name: "default-resourcequota"
2019-10-24 18:41:37 -05:00
data:
spec:
hard:
requests.cpu: '4'
requests.memory: '16Gi'
2019-11-12 16:37:40 -08:00
limits.cpu: '4'
limits.memory: '16Gi'
2019-10-24 18:41:37 -05:00
````