Limit Ranges, global setting and per namespace
This commit is contained in:
@@ -15,4 +15,4 @@ type: application
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.0
|
||||
version: 0.2.0
|
||||
|
||||
@@ -1,25 +1,44 @@
|
||||
{{- range .Values.namespaces }}
|
||||
{{- $limits := $.Values.pod.limits }}
|
||||
{{- if .pod }}
|
||||
{{- if .pod.limits }}
|
||||
{{- $limits = .pod.limits }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $overcommit := $.Values.pod.overcommit }}
|
||||
{{- if .pod }}
|
||||
{{- if .pod.overcommit }}
|
||||
{{- $overcommit = .pod.overcommit }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $defaults := $.Values.pod.defaults }}
|
||||
{{- if .pod }}
|
||||
{{- if .pod.defaults }}
|
||||
{{- $defaults = .pod.defaults }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: LimitRange
|
||||
metadata:
|
||||
name: resource-limits
|
||||
name: {{ .name }}
|
||||
namespace: {{ .name }}
|
||||
spec:
|
||||
limits:
|
||||
- type: Container
|
||||
max:
|
||||
cpu: "4"
|
||||
cpu: 4
|
||||
memory: "8Gi"
|
||||
min:
|
||||
cpu: "100m"
|
||||
memory: "50Mi"
|
||||
default:
|
||||
cpu: "300m"
|
||||
memory: "200Mi"
|
||||
cpu: {{ $defaults.cpu }}
|
||||
memory: {{ $defaults.memory }}
|
||||
defaultRequest:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
cpu: {{ $defaults.cpu }}
|
||||
memory: {{ $defaults.memory }}
|
||||
maxLimitRequestRatio:
|
||||
cpu: "10"
|
||||
memory: "1"
|
||||
cpu: {{ $overcommit.cpu }}
|
||||
memory: {{ $overcommit.memory }}
|
||||
{{- end }}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
{{- range .Values.namespaces }}
|
||||
{{- $budget := $.Values.budget }}
|
||||
{{- if .budget }}
|
||||
{{- $budget = .budget }}
|
||||
{{- $budget := $.Values.namespace.budget }}
|
||||
{{- if .namespace }}
|
||||
{{- if .namespace.budget }}
|
||||
{{- $budget = .namespace.budget }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $overcommit := $.Values.namespace.overcommit }}
|
||||
{{- if .namespace }}
|
||||
{{- if .namespace.overcommit }}
|
||||
{{- $overcommit = .namespace.overcommit }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -10,8 +18,8 @@ metadata:
|
||||
name: {{ .name }}
|
||||
spec:
|
||||
hard:
|
||||
limits.cpu: {{ $budget.cpu | mul $.Values.overcommit.cpu }}
|
||||
limits.memory: {{ $budget.memory | regexFind "[1-9]+" | mul $.Values.overcommit.memory }}{{ $budget.memory | regexFind "[a-zA-Z]+" }}
|
||||
limits.cpu: {{ $budget.cpu | mul $overcommit.cpu }}
|
||||
limits.memory: {{ $budget.memory | regexFind "[1-9]+" | mul $overcommit.memory }}{{ $budget.memory | regexFind "[a-zA-Z]+" }}
|
||||
requests.cpu: {{ $budget.cpu }}
|
||||
requests.memory: {{ $budget.memory }}
|
||||
requests.storage: {{ $budget.storage }}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
suite: test deployment
|
||||
templates:
|
||||
- limit-range.yaml
|
||||
tests:
|
||||
- it: Should set default limits
|
||||
set:
|
||||
pod:
|
||||
limits:
|
||||
cpu: 4
|
||||
memory: "8Gi"
|
||||
defaults:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
overcommit:
|
||||
cpu: 10
|
||||
memory: 2
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.limits
|
||||
value:
|
||||
- type: Container
|
||||
max:
|
||||
cpu: 4
|
||||
memory: "8Gi"
|
||||
min:
|
||||
cpu: "100m"
|
||||
memory: "50Mi"
|
||||
default:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
defaultRequest:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
maxLimitRequestRatio:
|
||||
cpu: 10
|
||||
memory: 2
|
||||
- it: Should set namespace specific limits
|
||||
set:
|
||||
namespaces:
|
||||
- name: staging
|
||||
pod:
|
||||
limits:
|
||||
cpu: 4
|
||||
memory: "8Gi"
|
||||
defaults:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
overcommit:
|
||||
cpu: 10
|
||||
memory: 2
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.limits
|
||||
value:
|
||||
- type: Container
|
||||
max:
|
||||
cpu: 4
|
||||
memory: "8Gi"
|
||||
min:
|
||||
cpu: "100m"
|
||||
memory: "50Mi"
|
||||
default:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
defaultRequest:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
maxLimitRequestRatio:
|
||||
cpu: 10
|
||||
memory: 2
|
||||
@@ -4,13 +4,14 @@ templates:
|
||||
tests:
|
||||
- it: Should set default quota values
|
||||
set:
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
namespace:
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.hard
|
||||
@@ -24,17 +25,19 @@ tests:
|
||||
set:
|
||||
namespaces:
|
||||
- name: staging
|
||||
budget:
|
||||
cpu: 8
|
||||
memory: "16Gi"
|
||||
storage: "100Gi"
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
namespace:
|
||||
budget:
|
||||
cpu: 8
|
||||
memory: "16Gi"
|
||||
storage: "100Gi"
|
||||
namespace:
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.hard
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
namespaces:
|
||||
- name: staging
|
||||
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
namespace:
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
|
||||
podOvercommit:
|
||||
cpu: 10
|
||||
memory: 2
|
||||
pod:
|
||||
limits:
|
||||
cpu: 4
|
||||
memory: "8Gi"
|
||||
defaults:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
overcommit:
|
||||
cpu: 10
|
||||
memory: 2
|
||||
|
||||
Binary file not shown.
+30
-21
@@ -2,17 +2,17 @@ apiVersion: v1
|
||||
entries:
|
||||
cron-job:
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.304402199+01:00"
|
||||
created: "2020-11-03T12:53:11.923484754+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: dc733bf1d136a6db248cdfafefe75fe2e7caabddd6230c1940f005868b732a01
|
||||
digest: c23b341a73f89c87f78dc9d5b7e5ea26f6914618c8d86fad3ade7b4d4d63cc14
|
||||
name: cron-job
|
||||
type: application
|
||||
urls:
|
||||
- https://chart.onechart.dev/cron-job-0.1.2.tgz
|
||||
version: 0.1.2
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.304138101+01:00"
|
||||
created: "2020-11-03T12:53:11.923240273+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: afab9ba533a4686827b54b0dad64f5bbf76f7fbc075e35fb1034689db9ab9dda
|
||||
@@ -22,7 +22,7 @@ entries:
|
||||
- https://chart.onechart.dev/cron-job-0.1.1.tgz
|
||||
version: 0.1.1
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.303740199+01:00"
|
||||
created: "2020-11-03T12:53:11.922991885+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: 01f9fa40c1c4085d7688474ab00c9e9d21bd1d0793db6b75f2edda0e18456282
|
||||
@@ -33,7 +33,16 @@ entries:
|
||||
version: 0.1.0
|
||||
namespaces:
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.304875434+01:00"
|
||||
created: "2020-11-03T12:53:11.923931666+01:00"
|
||||
description: Chart to create namespaces and their defaults
|
||||
digest: 2579e57858f39c6b694e97c7d268f7488588c46b478e7791d7ced4f0c5817d32
|
||||
name: namespaces
|
||||
type: application
|
||||
urls:
|
||||
- https://chart.onechart.dev/namespaces-0.2.0.tgz
|
||||
version: 0.2.0
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T12:53:11.923687794+01:00"
|
||||
description: Chart to create namespaces and their defaults
|
||||
digest: 88b06d78a9d1bda6f2ee15b1fad7f25399ac25c2320fb9a8dfa1a4fd14afdf6e
|
||||
name: namespaces
|
||||
@@ -43,17 +52,17 @@ entries:
|
||||
version: 0.1.0
|
||||
onechart:
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.310524127+01:00"
|
||||
created: "2020-11-03T12:53:11.928438556+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: 4b997a4af439f7999a5490fd54aa4ec8b45e2e84bc92ce6741d99a406367a254
|
||||
digest: d1454b430eb7131d0d450f7c0a8a6698278893c61e03d48649a8112dfcf42b72
|
||||
name: onechart
|
||||
type: application
|
||||
urls:
|
||||
- https://chart.onechart.dev/onechart-0.7.1.tgz
|
||||
version: 0.7.1
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.310142507+01:00"
|
||||
created: "2020-11-03T12:53:11.92809038+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: 4bf90835f287917671ec40b5b395da9332cf18e70f248d250f8d5a72360dcb4e
|
||||
@@ -63,7 +72,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.7.0.tgz
|
||||
version: 0.7.0
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.309709577+01:00"
|
||||
created: "2020-11-03T12:53:11.927775348+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: 0cade489fc74a040f5e7f71d01c6fa00d3f68b4752a4d8234ccf2c1504b4c0a1
|
||||
@@ -73,7 +82,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.6.1.tgz
|
||||
version: 0.6.1
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.309343229+01:00"
|
||||
created: "2020-11-03T12:53:11.927480032+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: d607820a7e104eaaa88c153c1f2f7f409ef4c612ad747caeb3a671cf3fce03d4
|
||||
@@ -83,7 +92,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.6.0.tgz
|
||||
version: 0.6.0
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.308980383+01:00"
|
||||
created: "2020-11-03T12:53:11.927199369+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: ddf7cf87402095d62855898744b805115fdf86c4b295e0a4def0c50408fd9138
|
||||
@@ -93,7 +102,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.5.1.tgz
|
||||
version: 0.5.1
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.308615988+01:00"
|
||||
created: "2020-11-03T12:53:11.926937214+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: adf3c2cf3a27e58ec75620599e0e1c2031a7410a061a590317beeff6d8a9ad69
|
||||
@@ -103,7 +112,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.5.0.tgz
|
||||
version: 0.5.0
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.308260874+01:00"
|
||||
created: "2020-11-03T12:53:11.926677573+01:00"
|
||||
description: One chart to rule them all. A generic Helm chart for your application
|
||||
deployments. Because no-one can remember the Kubernetes yaml syntax.
|
||||
digest: 8dab33263c4e632aeb4656c666871440b589497b70e76a1d6c3a5e3db1a30bba
|
||||
@@ -113,7 +122,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.4.0.tgz
|
||||
version: 0.4.0
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.307836329+01:00"
|
||||
created: "2020-11-03T12:53:11.926387295+01:00"
|
||||
description: A generic Helm chart for your application deployments
|
||||
digest: fbaf6139e0ef8ad9a87cc1e41a97c7d25fdcf7ea17fa6364952f1a851a87480a
|
||||
name: onechart
|
||||
@@ -122,7 +131,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.3.2.tgz
|
||||
version: 0.3.2
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.307507987+01:00"
|
||||
created: "2020-11-03T12:53:11.92616589+01:00"
|
||||
description: A generic Helm chart for your application deployments
|
||||
digest: bd6f5b1865ab9b05fc6925c163ab8045235bd2723dba31f09d5083d24322d1f8
|
||||
name: onechart
|
||||
@@ -131,7 +140,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.3.1.tgz
|
||||
version: 0.3.1
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.307183326+01:00"
|
||||
created: "2020-11-03T12:53:11.925934518+01:00"
|
||||
description: A generic Helm chart for your application deployments
|
||||
digest: c79cef21eceab948144a289298cdf1e20e77a0782a883d7d65f9e709ccbbc271
|
||||
name: onechart
|
||||
@@ -140,7 +149,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.3.0.tgz
|
||||
version: 0.3.0
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.306851679+01:00"
|
||||
created: "2020-11-03T12:53:11.925632083+01:00"
|
||||
description: A generic Helm chart for your application deployments
|
||||
digest: dd814ac5d08d5e6163a1b769df6803f5cb0f09d906045086dfcc5be522bb1ec3
|
||||
name: onechart
|
||||
@@ -149,7 +158,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.2.0.tgz
|
||||
version: 0.2.0
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.306484052+01:00"
|
||||
created: "2020-11-03T12:53:11.925351758+01:00"
|
||||
description: A generic Helm chart for your application deployments
|
||||
digest: e46062df8053840cbfbba26c0a66a843a79f15a0b43a145ed019327513bd5098
|
||||
name: onechart
|
||||
@@ -158,7 +167,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.1.2.tgz
|
||||
version: 0.1.2
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.306088852+01:00"
|
||||
created: "2020-11-03T12:53:11.925075516+01:00"
|
||||
description: A generic Helm chart for your application deployments
|
||||
digest: a7bbc8b7dcc008e89156cd1830282b7d39c0592e82ccdcefb77a25a42eca2a3d
|
||||
name: onechart
|
||||
@@ -167,7 +176,7 @@ entries:
|
||||
- https://chart.onechart.dev/onechart-0.1.1.tgz
|
||||
version: 0.1.1
|
||||
- apiVersion: v2
|
||||
created: "2020-11-03T11:55:21.305769568+01:00"
|
||||
created: "2020-11-03T12:53:11.924239159+01:00"
|
||||
description: A generic Helm chart for your application deployments
|
||||
digest: 1ed8c0645abdae6c950526e9c5410dc056847a11700dc7def5f1c55eb7de0cd4
|
||||
name: onechart
|
||||
@@ -175,4 +184,4 @@ entries:
|
||||
urls:
|
||||
- https://chart.onechart.dev/onechart-0.1.0.tgz
|
||||
version: 0.1.0
|
||||
generated: "2020-11-03T11:55:21.303195966+01:00"
|
||||
generated: "2020-11-03T12:53:11.922637823+01:00"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+5
-4
@@ -2,7 +2,8 @@ namespaces:
|
||||
- name: staging
|
||||
annotations:
|
||||
linkerd.io/inject: enabled
|
||||
budget:
|
||||
cpu: 8
|
||||
memory: "16Gi"
|
||||
storage: "100Gi"
|
||||
namespace:
|
||||
budget:
|
||||
cpu: 8
|
||||
memory: "16Gi"
|
||||
storage: "100Gi"
|
||||
|
||||
Reference in New Issue
Block a user