<@U06RKAMK0UC> how do i add tolerations for k8s in...
# ask-ai
m
@ancient-wolf-19325 how do i add tolerations for k8s in the task deployment?
j
To add tolerations for Kubernetes in a Flyte task deployment, you can use a
PodTemplate
in your task definition. This allows you to specify tolerations directly in the pod specification. Here's an example:
Copy code
from flytekit import task, PodTemplate
from kubernetes.client import V1Container, V1PodSpec, V1Toleration

@task(
    pod_template=PodTemplate(
        primary_container_name="primary",
        pod_spec=V1PodSpec(
            containers=[
                V1Container(
                    name="primary",
                    image="your-image",
                ),
            ],
            tolerations=[
                V1Toleration(
                    key="your-key",
                    operator="Equal",
                    value="your-value",
                    effect="NoSchedule",
                ),
            ],
        ),
    ),
)
def your_task() -> None:
    # Task implementation
    pass
This example sets a toleration for the pod to be scheduled on nodes with a specific taint. Would you like more details on this configuration? Sources: - Implement Spark pod template overrides - BUG: Spark Task tolerations not applied with PodTemplate 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.