Skip to content

Commit

Permalink
feat(base-cluster/limit-ranges): allow templating in limitranges and …
Browse files Browse the repository at this point in the history
…resource quotas
  • Loading branch information
marvinWolff committed Dec 18, 2023
1 parent 8552925 commit da46223
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 65 deletions.
59 changes: 59 additions & 0 deletions charts/base-cluster/ci/limitrange-resourcequota-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
global:
serviceLevelAgreement: None
namespaces:
main0:
resources:
defaults:
requests:
cpu: 50m
memory: 100Mi
limits:
cpu: 500m
memory: 300Mi
quotas:
limits.cpu: "1"
limits.memory: 1Gi
main1:
resources:
defaults:
requests:
cpu: 50m
memory: 100Mi
limits:
cpu: 500m
memory: 300Mi
main2:
resources:
defaults:
requests:
cpu: 50m
memory: 100Mi
quotas:
limits.cpu: "1"
limits.memory: 1Gi
main3:
resources:
defaults:
requests:
cpu: 50m
memory: 100Mi
main4:
resources:
defaults:
limits:
cpu: 500m
memory: 300Mi
quotas:
limits.cpu: "1"
limits.memory: 1Gi
main5:
resources:
defaults:
limits:
cpu: 500m
memory: 300Mi
main6:
resources:
quotas:
limits.cpu: "1"
limits.memory: 1Gi

Check failure on line 59 in charts/base-cluster/ci/limitrange-resourcequota-values.yaml

View workflow job for this annotation

GitHub Actions / lint helm chart (base-cluster)

59:29 [new-line-at-end-of-file] no new line character at the end of file
18 changes: 14 additions & 4 deletions charts/base-cluster/templates/global/namespaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ spec:
{{- if $namespace.resources.defaults -}}
{{/* this section defines default limits */}}
{{- with $namespace.resources.defaults.limits -}}
{{- $limits = set $limits "default" . -}}
{{- $defaultLimits := dict -}}
{{- range $resource, $limit := . -}}
{{- $defaultLimits = set $defaultLimits $resource (include "common.tplvalues.render" (dict "value" $limit "context" $)) -}}
{{- end -}}
{{- $limits = set $limits "default" $defaultLimits -}}
{{- end -}}
{{/* this section defines default requests */}}
{{- with $namespace.resources.defaults.requests -}}
{{- $limits = set $limits "defaultRequest" . -}}
{{- $defaultRequests := dict -}}
{{- range $resource, $request := . -}}
{{- $defaultRequests = set $defaultRequests $resource (include "common.tplvalues.render" (dict "value" $request "context" $)) -}}
{{- end -}}
{{- $limits = set $limits "defaultRequest" $defaultRequests -}}
{{- end -}}
{{- end }}
{{- end }}
Expand All @@ -39,9 +47,11 @@ metadata:
namespace: {{ $name }}
labels: {{- include "common.labels.standard" $ | nindent 4 }}
spec:
{{- $quotas := dict -}}
{{- with $namespace.resources.quotas -}}
{{- $quotas = . }}
{{- $quotas := dict -}}
{{- range $resource, $quota := . -}}
{{- $quotas = set $quotas $resource (include "common.tplvalues.render" (dict "value" $quota "context" $)) -}}
{{- end }}
hard: {{- $quotas | toYaml | nindent 4 }}
{{- end }}
{{- end }}
Expand Down
61 changes: 0 additions & 61 deletions charts/base-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ global:
condition: "{{ not (empty .Values.dns.provider) }}"
additionalLabels:
app.kubernetes.io/component: ingress
resources:
defaults:
requests:
cpu: 20m
memory: 100Mi
limits:
cpu: 100m
memory: 200Mi
quotas:
limits.cpu: "1"
limits.memory: 500Mi
cert-manager:
additionalLabels:
app.kubernetes.io/component: cert-manager
Expand All @@ -39,32 +28,10 @@ global:
condition: "{{ .Values.ingress.enabled }}"
additionalLabels:
app.kubernetes.io/component: ingress
resources:
defaults:
requests:
cpu: 20m
memory: 100Mi
limits:
cpu: 100m
memory: 200Mi
quotas:
limits.cpu: "1"
limits.memory: 500Mi
kyverno:
condition: "{{ .Values.kyverno.enabled }}"
additionalLabels:
app.kubernetes.io/component: kyverno
resources:
defaults:
requests:
cpu: 350m
memory: 350Mi
limits:
cpu: 800m
memory: 800Mi
quotas:
limits.cpu: 1500m
limits.memory: 1500Mi
monitoring:
condition: "{{ or .Values.monitoring.prometheus.enabled .Values.monitoring.metricsServer.enabled }}"
additionalLabels:
Expand All @@ -74,12 +41,6 @@ global:
requests:
cpu: 20m
memory: 100Mi
limits:
cpu: 100m
memory: 200Mi
quotas:
limits.cpu: "1"
limits.memory: 4000Mi
loki:
condition: "{{ .Values.monitoring.loki.enabled }}"
additionalLabels:
Expand All @@ -89,17 +50,6 @@ global:
condition: "{{ .Values.monitoring.securityScanning.enabled }}"
additionalLabels:
app.kubernetes.io/component: security
resources:
defaults:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 300m
memory: 1500Mi
quotas:
limits.cpu: 500Mi
limits.memory: 4Gi
nfs-server-provisioner:
condition: "{{ .Values.storage.readWriteMany.enabled }}"
additionalLabels:
Expand All @@ -109,17 +59,6 @@ global:
condition: "{{ .Values.backup.enabled }}"
additionalLabels:
app.kubernetes.io/component: backup
resources:
defaults:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 500m
memory: 500Mi
quotas:
limits.cpu: 1500Mi
limits.memory: 2Gi
certificates:
cluster-wildcard:
dnsNames: |-
Expand Down

0 comments on commit da46223

Please sign in to comment.