Hi! Can someone tell me if I can use `pull: prefec...
# prefect-getting-started
r
Hi! Can someone tell me if I can use
pull: prefect.deployments.steps.git_clone:
with Prefect flows running in a Kubernetes job? I'm exploring ways to speed up execution. Currently, whenever I update my flow code, I have to rebuild the image used in the Kubernetes job each time.
More broadly, how can I fetch the flow code when running it in a Kubernetes job? I'm unsure about what the
entrypoint
directive in my Prefect deployment YAML does when using my own container. Is it just a path variable? Or does Prefect still retrieve the entrypoint flow code in some manner?
k
you can absolutely use the
git_clone
pull step for kubernetes jobs. the
entrypoint
is the path to your flow function relative to the working directory (set either in your dockerfile or another pull step, or
/opt/prefect
if you're using a prefect base image and don't change the working directory). prefect will supply its own container startup command by default for running a flow, which will then use the entrypoint to execute your flow function, so you don't need to provide that kind of information in your dockerfile
upvote 1
r
I've played with the configuration a little bit. Here's what I've set up: prefect.yaml:
deployments:
- name: test-dep
path: /test-dir
entrypoint: test.py:sleep
work_pool:
name: my_k8s_work_pool
pull:
- prefect.deployments.steps.set_working_directory:
directory: /app
- prefect.deployments.steps.git_clone:
repository: <https://github.com/my_git_user/my_git_project.git>
dockerfile:
FROM prefecthq/prefect:2-python3.11-kubernetes
RUN mkdir /app
COPY test.py /app/test.py
From the execution logs, it seems that Prefect is searching for the flow function in
/app/my_git_project/test.py
. This indicates that it first enters the working directory
/app
and then navigates to the cloned
my_git_project
directory. It appears that the
path: /test-dir
directive is ignored in this case. Am I right?