Skip to content

Commit

Permalink
chore: ressources in template
Browse files Browse the repository at this point in the history
Signed-off-by: ThibaultFy <thibault.fouqueray@gmail.com>
  • Loading branch information
ThibaultFy committed Apr 24, 2024
1 parent 68fe33d commit 5768b41
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions backend/backend/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@

ISOLATED = to_bool(os.environ.get("ISOLATED"))

REQUESTS_RESOURCES = to_bool(os.environ.get("REQUESTS_RESOURCES"))

CONTENT_DISPOSITION_HEADER = {}

VIRTUAL_USERNAMES = {
Expand Down
7 changes: 6 additions & 1 deletion backend/builder/image_builder/image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
IMAGE_BUILD_TIMEOUT = settings.IMAGE_BUILD_TIMEOUT
KANIKO_CONTAINER_NAME = "kaniko"
HOSTNAME = settings.HOSTNAME
REQUESTS_RESSOURCES = settings.REQUESTS_RESSOURCES


def container_image_tag_from_function(function: orchestrator.Function) -> str:
Expand Down Expand Up @@ -307,7 +308,11 @@ def _build_container(dockerfile_mount_path: str, image_tag: str) -> kubernetes.c
args=args,
volume_mounts=volume_mounts,
security_context=container_security_context,
resources=get_resources_requirements(cpu_request="1000m", memory_request="4Gi", memory_limit="32Gi"),
resources=(
get_resources_requirements(cpu_request="1000m", memory_request="4Gi", memory_limit="32Gi")
if REQUESTS_RESSOURCES
else None
),
)


Expand Down
7 changes: 6 additions & 1 deletion backend/substrapp/compute_tasks/compute_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from substrapp.kubernetes_utils import get_security_context

NAMESPACE = settings.NAMESPACE
REQUESTS_RESSOURCES = settings.REQUESTS_RESSOURCES
logger = structlog.get_logger(__name__)


Expand Down Expand Up @@ -113,7 +114,11 @@ def create_pod(
args=None,
volume_mounts=volume_mounts + gpu_volume_mounts,
security_context=get_security_context(),
resources=get_resources_requirements(cpu_request="1000m", memory_request="1Gi", memory_limit="64Gi"),
resources=(
get_resources_requirements(cpu_request="1000m", memory_request="1Gi", memory_limit="64Gi")
if REQUESTS_RESSOURCES
else None
),
env=[kubernetes.client.V1EnvVar(name=env_name, value=env_value) for env_name, env_value in environment.items()],
**container_optional_kwargs,
)
Expand Down
2 changes: 2 additions & 0 deletions charts/substra-backend/templates/configmap-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ data:
COMPUTE_POD_RUN_AS_GROUP: {{ .Values.worker.computePod.securityContext.runAsGroup | quote }}
COMPUTE_POD_FS_GROUP: {{ .Values.worker.computePod.securityContext.fsGroup | quote }}

REQUESTS_RESOURCES: {{ .Values.requestsResources | quote }}

KANIKO_IMAGE: {{ include "common.images.name" .Values.kaniko.image }}
KANIKO_MIRROR: {{ .Values.kaniko.mirror | quote }}

Expand Down
3 changes: 2 additions & 1 deletion charts/substra-backend/templates/deployment-scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ spec:
mountPath: /var/substra/orchestrator/tls/client
{{ end }}
{{ end }}
{{ if .Values.scheduler.requestsRessources }}
{{- if .Values.requestsRessources }}
resources:
requests:
cpu: "1000m"
memory: "4Gi"
limits:
cpu: "2000m"
memory: "8Gi"
{{- end }}
volumes:
- name: runtime-db
emptyDir: {}
Expand Down
2 changes: 1 addition & 1 deletion charts/substra-backend/templates/deployment-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ spec:
successThreshold: {{ .Values.server.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.server.readinessProbe.failureThreshold }}
{{- end }}
{{- if .Values.server.resources }}
{{- if .Values.requestsRessources }}
resources:
requests:
cpu: "1000m"
Expand Down

0 comments on commit 5768b41

Please sign in to comment.