Skip to content

chore: Normalize how resources are set for each container #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 11, 2025
47 changes: 47 additions & 0 deletions charts/invenio/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,50 @@ DEPRECATION WARNING:
`invenio.datacite.existingSecret` will be removed in a future release.

{{- end }}

{{/*
BEGIN: Warning on unset resources.
*/}}

{{- $fieldsToCheckForResources := list
"flower"
"haproxy"
"kerberos.initContainers"
"kerberos"
"nginx"
"web.initContainers"
"web"
"worker"
"workerBeat"
-}}

{{- $fieldsWithResourcesUnset := list -}}

{{- range $fieldsToCheckForResources -}}
{{- $path := splitList "." . -}}
{{- $values := $.Values -}}
{{- range $path -}}
{{- $values = index $values . -}}
{{- end -}}
{{- if not $values.resources -}}
{{ $fieldsWithResourcesUnset = append $fieldsWithResourcesUnset . -}}
{{- end -}}
{{- end -}}

{{- with $fieldsWithResourcesUnset }}

💡 MISSING RESOURCES: It seems like `resources` is unset for one or more containers. We strongly recommend that you set them. The `resources` field is unset in the following places:

{{- "\n" -}}
{{ range . }}
.Values.{{ . }}
{{- end }}

You can read more about resource management in Kubernetes here:
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

{{- end }}

{{/*
END: Warning on unset resources.
*/}}
2 changes: 0 additions & 2 deletions charts/invenio/templates/flower/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ spec:
{{- . | toYaml | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.flower.resources }}
resources: {{- toYaml .Values.flower.resources | nindent 12 }}
{{- end }}
volumeMounts:
- name: celery-config-volume
mountPath: /var/celery
Expand Down
2 changes: 0 additions & 2 deletions charts/invenio/templates/haproxy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ spec:
- name: haproxy-config
mountPath: /usr/local/etc/haproxy/backup-website.http
subPath: backup-website.http
{{- if .Values.haproxy.resources }}
resources: {{- toYaml .Values.haproxy.resources | nindent 12 }}
{{- end }}
volumes:
- name: haproxy-config
configMap:
Expand Down
11 changes: 2 additions & 9 deletions charts/invenio/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ spec:
"-c",
"uwsgi --ini /opt/invenio/src/uwsgi/uwsgi.ini",
]
{{- if .Values.web.resources }}
resources: {{- toYaml .Values.web.resources | nindent 10 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ include "invenio.fullname" . }}-config
Expand Down Expand Up @@ -147,9 +145,7 @@ spec:
port: 8080
initialDelaySeconds: 15
timeoutSeconds: 1
{{- if .Values.nginx.resources }}
resources: {{- toYaml .Values.nginx.resources | nindent 10 }}
{{- end }}
securityContext:
{{- with .Values.nginx.securityContext }}
{{- toYaml . | nindent 10 }}
Expand Down Expand Up @@ -206,10 +202,7 @@ spec:
"-c",
"cp -R {{ .Values.web.assets.location }}/. /opt/nginx-invenio-assets/",
]
{{- if .Values.web.initContainers.resources }}
resources:
{{- toYaml .Values.web.initContainers.resources | nindent 12 }}
{{- end }}
resources: {{- toYaml .Values.web.initContainers.resources | nindent 12 }}
securityContext:
{{- with .Values.web.initContainers.securityContext }}
{{- toYaml . | nindent 12 }}
Expand All @@ -225,7 +218,7 @@ spec:
envFrom:
- secretRef:
name: {{ .Values.kerberos.secret_name }}
resources: {{- toYaml .Values.kerberos.resources | nindent 12 }}
resources: {{- toYaml .Values.kerberos.initContainers.resources | nindent 12 }}
volumeMounts:
- name: kerberos-credentials-cache
mountPath: /tmp
Expand Down
10 changes: 0 additions & 10 deletions charts/invenio/templates/worker-beat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,7 @@ spec:
- "celery -A {{ .Values.worker.app }} inspect ping"
initialDelaySeconds: 20
timeoutSeconds: 30
{{- if .Values.worker.resources }}
resources: {{- toYaml .Values.workerBeat.resources | nindent 10 }}
{{- else }}
resources:
requests:
cpu: 500m
memory: 200Mi
limits:
cpu: '2'
memory: 500Mi
{{- end }}
securityContext:
{{- with .Values.workerBeat.podSecurityContext }}
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 1 addition & 3 deletions charts/invenio/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ spec:
"-c",
"celery -A {{ .Values.worker.app }} worker -c {{ .Values.worker.concurrency }} -l {{ .Values.worker.log_level }}"
]
{{- if .Values.worker.resources }}
resources: {{- toYaml .Values.worker.resources | nindent 12 }}
{{- end }}
securityContext:
{{- with .Values.worker.securityContext }}
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -127,7 +125,7 @@ spec:
envFrom:
- secretRef:
name: {{ .Values.kerberos.secret_name }}
resources: {{- toYaml .Values.kerberos.resources | nindent 12 }}
resources: {{- toYaml .Values.kerberos.initContainers.resources | nindent 12 }}
volumeMounts:
- name: kerberos-credentials-cache
mountPath: /tmp
Expand Down
Loading