Skip to content

Commit

Permalink
chore: toYaml
Browse files Browse the repository at this point in the history
Signed-off-by: ThibaultFy <thibault.fouqueray@gmail.com>
  • Loading branch information
ThibaultFy committed Jun 24, 2024
1 parent 07ec984 commit 7545c37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions backend/substrapp/compute_tasks/compute_pod.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import json
import yaml
import os

import kubernetes
Expand Down Expand Up @@ -129,9 +129,9 @@ def create_pod(
image_pull_secrets = None
spec = kubernetes.client.V1PodSpec(
restart_policy="Never",
affinity=json.loads(os.getenv("COMPUTE_POD_AFFINITY")),
node_selector=json.loads(os.getenv("COMPUTE_POD_NODE_SELECTOR")),
tolerations=json.loads(os.getenv("COMPUTE_POD_TOLERATIONS")),
affinity=yaml.safe_load(os.getenv("COMPUTE_POD_AFFINITY")),
node_selector=yaml.safe_load(os.getenv("COMPUTE_POD_NODE_SELECTOR")),
tolerations=yaml.safe_load(os.getenv("COMPUTE_POD_TOLERATIONS")),
containers=[container_compute],
volumes=volumes + gpu_volume,
security_context=get_pod_security_context(),
Expand Down
6 changes: 3 additions & 3 deletions charts/substra-backend/templates/statefulset-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ spec:
fieldRef:
fieldPath: metadata.name
- name: COMPUTE_POD_AFFINITY
value: {{ .Values.worker.computePod.affinity | quote }} # TODO see if it works to inject POD_NAME venv in string
value: {{ toYaml .Values.worker.computePod.affinity | quote }} # TODO see if it works to inject POD_NAME venv in string
- name: COMPUTE_POD_NODE_SELECTOR
value: {{ .Values.worker.computePod.nodeSelector | quote }}
value: {{ toYaml .Values.worker.computePod.nodeSelector | quote }}
- name: COMPUTE_POD_TOLERATIONS
value: {{ .Values.worker.computePod.tolerations | quote }}
value: {{ toYaml .Values.worker.computePod.tolerations | quote }}
- name: COMPUTE_POD_RESOURCES
value: {{ toYaml .Values.worker.computePod.resources | quote }}
- name: COMPUTE_POD_MAX_STARTUP_WAIT_SECONDS
Expand Down
17 changes: 9 additions & 8 deletions charts/substra-backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -373,18 +373,19 @@ worker:
## @param worker.computePod.tolerations Toleration labels for pod assignment
##
tolerations: []
## @param worker.computePod.affinity Worker compute pod container affinity
## @param worker.computePod.affinity Worker compute pod container affinity. Pass as a string in order to catch the generated pod name on the statefuset environment variable PODNAME.
##
## '{"podAffinity": {"requiredDuringSchedulingIgnoredDuringExecution": {"topologyKey":"kubernetes.io/hostname", "labelSelector": {"matchExpressions":{"key":"statefulset.kubernetes.io/pod-name", "operator":"In","values":"$POD_NAME"}}}}}'
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: statefulset.kubernetes.io/pod-name
operator: In
values:
- $(POD_NAME)
topologyKey: kubernetes.io/hostname"
- labelSelector:
matchExpressions:
- key: statefulset.kubernetes.io/pod-name
operator: In
values:
- POD_NAME
topologyKey: kubernetes.io/hostname
events:
## @param worker.events.enabled Enable event service
##
Expand Down

0 comments on commit 7545c37

Please sign in to comment.