https://prefect.io logo
Title
e

Emma Rizzi

01/13/2023, 1:27 PM
Hello, I'm using prefect 1 with kubernetes agents, so far i used to launch through
prefect agent kubernetes start
and i am trying to migrate to
prefect agent kubernetes install
to generate a yaml file. I use the --job-template option which is not available with agent *install*, is there a workaround ?
c

Christopher Boyd

01/13/2023, 2:38 PM
Hi Emma,
kubernetes start
and
kubernetes install
are two separate commands. Here is the template that comes by default: https://github.com/PrefectHQ/prefect/blob/1.x/src/prefect/agent/kubernetes/job_template.yaml You can pass it in when you start the agent: https://docs-v1.prefect.io/orchestration/agents/kubernetes.html#custom-job-template
e

Emma Rizzi

01/13/2023, 3:46 PM
Hi @Christopher Boyd i would like to stop using the command
kubernetes start
to launch my agent as a kubernetes process, hence why i used
kubernetes install
to generate the yaml file but still miss the job template and I can't find how to add it 😕
c

Christopher Boyd

01/13/2023, 3:47 PM
Are you running in cluster, or external to the cluster
Or that’s what you’re looking tod o - you’re looking to run the agent in-cluster, and pass in a job spec
e

Emma Rizzi

01/13/2023, 3:53 PM
I'm not sure to understand the question 🤔 i execute the command outside of the cluster (with kubeconfig) where my actual agent is running, I want the agent inside the cluster but with the job template as it holds needed configuration
Yes thats exactly it!
c

Christopher Boyd

01/13/2023, 3:53 PM
Ok, I understand now, I’ll need a few minutes
e

Emma Rizzi

01/13/2023, 3:54 PM
Thanks a lot, no rush as its getting late in my location Ill probably continue next week 🙂
c

Christopher Boyd

01/13/2023, 4:14 PM
If you have a standard job template you would like to use, you can replace the job_template in the image: https://github.com/PrefectHQ/prefect/blob/1.x/src/prefect/agent/kubernetes/job_template.yaml
alternatively, you can create a new job template in the working directory of the image, and just pass that in to the start command with --job-template on the pod spec
e

Emma Rizzi

01/13/2023, 4:17 PM
Thanks a lot ! I will try those and keep you updated 😊
c

Christopher Boyd

01/13/2023, 4:23 PM
essentially, it’s just taking the default image in the deployment spec: prefecthq/prefect:1.4.1-python3.7 and updating to include your own job-template in the image
note, the path can be anywhere in the image since you can specify with the --job-template command
so you can put it in /tmp or something in the new image
then in the deployment.yaml, the start command would be like:
prefect kubernetes start --job-template /tmp/custom_job.yaml
e

Emma Rizzi

02/27/2023, 2:35 PM
@Christopher Boyd Finally had time to complete that, I did as you suggested . For anyone stumbling accross this, I built a custom prefect image containing my job_template, changed the start command in the agent.yaml generated by kubernetes install, and I also had to apply this file in the same workspace https://github.com/PrefectHQ/prefect/blob/1.x/src/prefect/agent/kubernetes/rbac.yaml to have the correct permissions on my agent. It worked as intended, thanks a lot 🙂
🙌 1
:catjam: 1