<@ULVA73B9P> i have dev env and staging env with k...
# ask-marvin
o
@Marvin i have dev env and staging env with kubernetes deploy the production is in kubernetes how many prefect servers other teams use? one per stage or only one?
m
thought for 242.6 seconds
Great question. Short answer: it depends on whether you’re using Prefect Cloud or self-hosting Prefect Server, and how much isolation you need. First, a quick clarifier: are you self-hosting Prefect Server or using Prefect Cloud? Recommendations by setup - Prefect Cloud - Typical: one account with separate workspaces per environment (dev, staging, prod). No separate “servers” needed. - Use separate work pools and workers per Kubernetes cluster/namespace. - Links: Workspaces, Work pools, Workers - Self-hosted Prefect Server - Common patterns we see: - 3 servers (one per env): strongest isolation (own DB, RBAC/isolation by environment boundary), more ops overhead. - 2 servers (dev+staging shared, prod isolated): good balance for many teams. - 1 server for all envs: simplest ops, but no hard isolation (everyone can see everything) and shared blast radius. - In all cases, run separate Kubernetes workers per environment/cluster, and point them at the right work pool and API URL. How to wire environments (self-hosted or Cloud) - Route each environment with PREFECT_API_URL:
Copy code
# dev
export PREFECT_API_URL="<https://prefect-dev.mycompany.com/api>"
# staging
export PREFECT_API_URL="<https://prefect-stg.mycompany.com/api>"
# prod
export PREFECT_API_URL="<https://prefect-prod.mycompany.com/api>"
- Create environment-specific work pools and run workers in each cluster:
Copy code
prefect work-pool create dev-k8s --type kubernetes
prefect work-pool create stg-k8s --type kubernetes
prefect work-pool create prod-k8s --type kubernetes

# In each cluster/namespace:
prefect worker start -p dev-k8s --type kubernetes
prefect worker start -p stg-k8s --type kubernetes
prefect worker start -p prod-k8s --type kubernetes
Docs: Work pools, Workers. If you’re self-hosting and need HA, see Scale self-hosted Prefect. What I typically recommend - If you’re self-hosting and have prod in Kubernetes: run a dedicated Prefect Server for prod, and either - a second server for dev+staging, or - separate servers per env if you have compliance/strict isolation needs. - If you’re on Prefect Cloud: one account, separate workspaces per env; use per-env work pools and per-cluster workers. If you can share whether you’re on Cloud vs self-hosted and any isolation/compliance requirements, I can suggest a concrete layout (including Helm values or infra sketches) for dev, staging, and prod.