https://prefect.io logo
#prefect-community
Title
# prefect-community
c

Cansu Kavılı

11/21/2022, 8:47 PM
hey everyone! 👋🏻 I am running Prefect Orion and the agents on a Kubernetes cluster and I was looking for a way to define Blocks as code manner. Deployment of Prefect itself with GitOps approach is super easy (nice helm chart!) but I do not want to define my Blocks via UI, I want them to persist and be consistent every time I reinstall Prefect..is there a way to achieve that? Thank you!
1
r

Ryan Peden

11/21/2022, 8:51 PM
A few general principles to go with Anna's excellent example: Any block you can create via the UI can also be created in Python by: 1. Importing the block's class. 2. Passing any parameters you would have set in the UI to the block's constructor. 3. Calling the block's
save
method.
c

Cansu Kavılı

11/21/2022, 8:53 PM
thanks a lot for the swift response @Anna Geller and @Ryan Peden I didn't know about
save_block
🤸‍♀️ just out of curiosity - do you have any plans to have a more k8s native way to generate prefect resources like block or deployment? like a controller that sees the definitions on k8s and generates Block or Deployment on Prefect 🌿
r

Ryan Peden

11/21/2022, 9:06 PM
Not that I'm aware of, but if you think that would be valuable I encourage you to open an issue in the
prefect-kubernetes
GitHub repo: https://github.com/PrefectHQ/prefect-kubernetes Even if we don't have current plans for this, many features begin with a user requesting something and explaining why it would be useful. 😄
😁 1
c

Cansu Kavılı

11/21/2022, 9:12 PM
hahah thanks for the link! 🙈