New RunLLM response generated: >>>*# Question* He...
# runllm-flyte-trial
j
New RunLLM response generated: >>>*# Question* Hello all. Is there a good way to ensure that all of the tasks in a workflow's pods are scheduled on the same node? It seems that by default the
execution-id
label is placed on each scheduled pod, but because podAffinity / podAntiAffinity rules do not know what
execution-id
label the pod its trying to schedule has before its created, its hard to tell in which node to place the pod on. Any ideas? Thanks so much # Answer To ensure that all tasks in a workflow's pods are scheduled on the same node, you can use the
nodeSelector
field in the pod specification. This can be done by configuring the
nodeSelector
for each task in the workflow to target the same node. Here's an example of how to set the
nodeSelector
for a task using Flyte's Python SDK:
Copy code
import time
from flytekit import task, workflow, Resources
from flytekitplugins.pod import Pod
from kubernetes.client.models import V1PodSpec

@task(
    task_config=Pod(
        pod_spec=V1PodSpec(
            containers=[],
            node_selector={"node_group": "memory"},
        ),
    ),
    requests=Resources(
        mem="1G",
    ),
)
def pod_task() -> str:
    return "Hello from pod task!"

@workflow
def pod_workflow() -> str:
    return pod_task()
This example sets the
nodeSelector
to target nodes labeled with
node_group: memory
. You can adjust the
node_selector
field to match the labels of the nodes you want to target. Would you like more details on this approach or other potential solutions? Sources: - Flytesnacks Pod Example Slack Link https://.slack.com/archives/CP2HDHKE1/p1728658589.034739 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.