From 8343eaf0a8bf75519bbb0f47706c9f3d5a835597 Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Fri, 15 Nov 2019 18:32:24 -0800 Subject: [PATCH 1/3] add generate rule for default limitrange --- samples/best_practices/add_ns_quota.yaml | 18 ++++++++++++++++++ .../samples/best_practices/add_ns_quota.yaml | 3 +++ 2 files changed, 21 insertions(+) diff --git a/samples/best_practices/add_ns_quota.yaml b/samples/best_practices/add_ns_quota.yaml index 1e17ce4970..9ae66b6260 100644 --- a/samples/best_practices/add_ns_quota.yaml +++ b/samples/best_practices/add_ns_quota.yaml @@ -24,3 +24,21 @@ spec: requests.memory: '16Gi' limits.cpu: '4' limits.memory: '16Gi' + - name: generate-limitrange + match: + resources: + kinds: + - Namespace + generate: + kind: LimitRange + name: "default-limitrange" + data: + spec: + limits: + - default: + cpu: 500m + memory: 1Gi + defaultRequest: + cpu: 200m + memory: 256Mi + type: Container diff --git a/test/scenarios/samples/best_practices/add_ns_quota.yaml b/test/scenarios/samples/best_practices/add_ns_quota.yaml index 2e4102ade8..649deea2fe 100644 --- a/test/scenarios/samples/best_practices/add_ns_quota.yaml +++ b/test/scenarios/samples/best_practices/add_ns_quota.yaml @@ -19,3 +19,6 @@ expected: - name: generate-resourcequota type: Generation success: true + - name: generate-limitrange + type: Generation + success: true From 42a6a87c41ae71fe0e2e692932964c20a89d6931 Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Mon, 18 Nov 2019 14:53:51 -0800 Subject: [PATCH 2/3] update markdown --- samples/AddNamespaceResourceQuota.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/samples/AddNamespaceResourceQuota.md b/samples/AddNamespaceResourceQuota.md index e3e8d1757f..07be527ffd 100644 --- a/samples/AddNamespaceResourceQuota.md +++ b/samples/AddNamespaceResourceQuota.md @@ -1,6 +1,6 @@ # Configure namespace limits and quotas -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. +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. The generated default limitrange sets the default quotas for a container. ## Additional Information @@ -32,4 +32,22 @@ spec: requests.memory: '16Gi' limits.cpu: '4' limits.memory: '16Gi' + - name: generate-limitrange + match: + resources: + kinds: + - Namespace + generate: + kind: LimitRange + name: "default-limitrange" + data: + spec: + limits: + - default: + cpu: 500m + memory: 1Gi + defaultRequest: + cpu: 200m + memory: 256Mi + type: Container ```` \ No newline at end of file From 67d98080020a87a294035488280e9f1aa54d0b4a Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Mon, 18 Nov 2019 16:55:14 -0800 Subject: [PATCH 3/3] change markdown and link name --- samples/{AddNamespaceResourceQuota.md => AddNamespaceQuotas.md} | 0 samples/README.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename samples/{AddNamespaceResourceQuota.md => AddNamespaceQuotas.md} (100%) diff --git a/samples/AddNamespaceResourceQuota.md b/samples/AddNamespaceQuotas.md similarity index 100% rename from samples/AddNamespaceResourceQuota.md rename to samples/AddNamespaceQuotas.md diff --git a/samples/README.md b/samples/README.md index cdb3ea1e6e..c89934ccc3 100644 --- a/samples/README.md +++ b/samples/README.md @@ -23,7 +23,7 @@ These policies are highly recommended. 13. [Require pod resource requests and limits](RequirePodRequestsLimits.md) 14. [Require pod `livenessProbe` and `readinessProbe`](RequirePodProbes.md) 15. [Add default network policy](AddDefaultNetworkPolicy.md) -16. [Add namespace resource quotas](AddNamespaceResourceQuota.md) +16. [Add namespace quotas](AddNamespaceQuotas.md) 17. [Add `safe-to-evict` for pods with `emptyDir` and `hostPath` volumes](AddSafeToEvict.md) ## Additional Policies