https://flyte.org logo
#ask-the-community
Title
# ask-the-community
d

Dan Butler

10/25/2023, 5:11 PM
This is more of a Kubernetes question, but perhaps folks can help. Does anyone have an example of using V1PersistentVolumeClaimVolumeSource to bind a PVC to a Flyte task?
s

Samhita Alla

10/26/2023, 7:13 AM
Should be doable with pod templates or the pod plugin. I don't have a concrete example but here's one I could find:
Copy code
@task(
   task_config=Pod(
       pod_spec=V1PodSpec(
           containers=[
               V1Container(
                   name="primary",
                   command=["/bin/sh"],
                   resources=V1ResourceRequirements(
                       requests={"cpu": "1", "memory": "500Mi"},
                       limits={"cpu": "1", "memory": "500Mi"},
                   ),
                   volume_mounts=[
                       V1VolumeMount(name="persistent-storage", mount_path="/data")
                   ],
               )
           ],
           volumes=[
               V1Volume(
                   name="persistent-storage",
                   persistent_volume_claim=V1PersistentVolumeClaimVolumeSource(
                       claim_name="fsx-claim"
                   ),
               )
           ],
       ),
       primary_container_name="primary",
   ),
   requests=Resources(
       mem="1Gi",
   ),
)
def my_pod_task() -> FlyteFile:
    ...
d

Dan Butler

10/26/2023, 2:01 PM
Thank you! Yes I figured it out in the end with something very similar to this