Resource Quotas, global setting and per namespace
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
{{- range .Values.namespaces }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: LimitRange
|
||||
metadata:
|
||||
name: resource-limits
|
||||
spec:
|
||||
limits:
|
||||
- type: Container
|
||||
max:
|
||||
cpu: "4"
|
||||
memory: "8Gi"
|
||||
min:
|
||||
cpu: "100m"
|
||||
memory: "50Mi"
|
||||
default:
|
||||
cpu: "300m"
|
||||
memory: "200Mi"
|
||||
defaultRequest:
|
||||
cpu: "200m"
|
||||
memory: "200Mi"
|
||||
maxLimitRequestRatio:
|
||||
cpu: "10"
|
||||
memory: "1"
|
||||
{{- end }}
|
||||
@@ -4,4 +4,8 @@ apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: {{ .name }}
|
||||
annotations:
|
||||
{{- if .annotations }}
|
||||
{{- toYaml .annotations | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{{- range .Values.namespaces }}
|
||||
{{- $budget := $.Values.budget }}
|
||||
{{- if .budget }}
|
||||
{{- $budget = .budget }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ResourceQuota
|
||||
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]+" }}
|
||||
requests.cpu: {{ $budget.cpu }}
|
||||
requests.memory: {{ $budget.memory }}
|
||||
requests.storage: {{ $budget.storage }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,15 @@
|
||||
suite: test deployment
|
||||
templates:
|
||||
- namespace.yaml
|
||||
tests:
|
||||
- it: Should place annotations
|
||||
set:
|
||||
namespaces:
|
||||
- name: staging
|
||||
annotations:
|
||||
linkerd.io/inject: enabled
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
linkerd.io/inject: enabled
|
||||
@@ -0,0 +1,46 @@
|
||||
suite: test deployment
|
||||
templates:
|
||||
- resource-quota.yaml
|
||||
tests:
|
||||
- it: Should set default quota values
|
||||
set:
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.hard
|
||||
value:
|
||||
limits.cpu: 64
|
||||
limits.memory: "64Gi"
|
||||
requests.cpu: 32
|
||||
requests.memory: "64Gi"
|
||||
requests.storage: "500Gi"
|
||||
- it: Should set namespace specific quotas
|
||||
set:
|
||||
namespaces:
|
||||
- name: staging
|
||||
budget:
|
||||
cpu: 8
|
||||
memory: "16Gi"
|
||||
storage: "100Gi"
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.hard
|
||||
value:
|
||||
limits.cpu: 16
|
||||
limits.memory: "16Gi"
|
||||
requests.cpu: 8
|
||||
requests.memory: "16Gi"
|
||||
requests.storage: "100Gi"
|
||||
@@ -1,2 +1,15 @@
|
||||
namespaces:
|
||||
- name: staging
|
||||
|
||||
budget:
|
||||
cpu: 32
|
||||
memory: "64Gi"
|
||||
storage: "500Gi"
|
||||
|
||||
overcommit:
|
||||
cpu: 2
|
||||
memory: 1
|
||||
|
||||
podOvercommit:
|
||||
cpu: 10
|
||||
memory: 2
|
||||
|
||||
Reference in New Issue
Block a user