<@ULVA73B9P> How do I run a prefect worker on a ku...
# ask-marvin
c
@Marvin How do I run a prefect worker on a kubernetes cluster workspace?
m
thought for 42.0 seconds
Here's how to run a Prefect worker on a Kubernetes cluster: 1. First, add the Prefect Helm repository and update it:
Copy code
bash
helm repo add prefect <https://prefecthq.github.io/prefect-helm>
helm repo update
2. Create a Kubernetes secret for your Prefect API key:
Copy code
bash
kubectl create secret generic prefect-api-key \
  --namespace=prefect \
  --from-literal=key=your-prefect-cloud-api-key
3. Create a
values.yaml
file to configure your worker. Here's a basic example:
Copy code
yaml
worker:
  apiKey:
    secretName: prefect-api-key
    secretKey: key
  workPool: your-work-pool-name
4. Install the worker using Helm:
Copy code
bash
helm install prefect-worker prefect/prefect-worker \
  --namespace prefect \
  -f values.yaml
Additional Configuration Tips: - If you're running on a serverless cluster (like EKS), you might want to increase the pod watch timeout to avoid issues with long startup times. Add this to your `values.yaml`:
Copy code
yaml
worker:
  podWatchTimeoutSeconds: 300
- You can specify resource requests and limits in your `values.yaml`:
Copy code
yaml
worker:
  resources:
    requests:
      cpu: "500m"
      memory: "512Mi"
    limits:
      cpu: "1000m"
      memory: "1Gi"
The worker will automatically poll for scheduled runs and execute them within your Kubernetes cluster. It handles the creation and management of pods for your flow runs. For more detailed information, you can refer to: - The official Kubernetes deployment guide: https://docs-3.prefect.io/v3/how-to-guides/deployment_infra/kubernetes - Example configurations: https://github.com/zzstoatzz/prefect-pack/tree/main/examples/run_a_prefect_worker/on_k8s/README.md Let me know if you need help with any specific configuration or if you run into any issues!