Nate
07/26/2023, 11:15 PMMarvin
07/26/2023, 11:16 PMNate
07/26/2023, 11:17 PMMarvin
07/26/2023, 11:18 PMkubectl create namespace prefect
.
2. Create a values.yaml
file to customize the Prefect worker configuration. Add the following contents to the file:
worker:
cloudApiConfig:
accountId: <target account ID>
workspaceId: <target workspace ID>
config:
workPool: <target work pool name>
These settings will ensure that the worker connects to the proper account, workspace, and work pool. You can view your Account ID and Workspace ID in your browser URL when logged into Prefect Cloud.
3. Now you can install the Prefect worker using the Helm chart with your custom values.yaml
file. Use the following command:
helm install prefect-worker prefect/prefect-worker --namespace=prefect -f values.yaml
4. Verify your deployment by checking the status of your Prefect worker deployment. You can do this with the following command: kubectl get pods -n prefect
. You should see the Prefect worker pod running.
And there you have it. You've now successfully deployed a Prefect worker using the Prefect Helm chart and configured the API key as a Kubernetes secret. The worker will now be able to communicate with Prefect Cloud and execute your Prefect flows.
I'm sure you're thrilled. I can hardly contain my own excitement.Nate
07/26/2023, 11:18 PMMarvin
07/26/2023, 11:18 PMNate
07/26/2023, 11:19 PMMarvin
07/26/2023, 11:19 PMNate
07/26/2023, 11:20 PMMarvin
07/26/2023, 11:21 PMNate
07/26/2023, 11:21 PMMarvin
07/26/2023, 11:21 PMpython
from prefect import Flow, Task
2. Next, you need to define your tasks. A task is a function that does something. Here's an example of a simple task:
python
class AddTask(Task):
def run(self, x: int, y: int) -> int:
return x + y
3. Now, you can define your flow. A flow is a collection of tasks with dependencies between them. Here's an example of a flow:
python
with Flow('My First Flow') as flow:
add_task = AddTask()
result = add_task(x=1, y=2)
4. Finally, you can run your flow:
python
flow.run() # returns: <Success: "All reference tasks succeeded.">
And there you have it. You've now successfully written a Prefect Flow. It's a momentous occasion, comparable to watching a leaf fall from a tree. I'm sure you're thrilled. I can hardly contain my own excitement.Nate
07/26/2023, 11:21 PMMarvin
07/26/2023, 11:22 PM