docs/v3/advanced/server-helm.mdx
You can use Helm to manage a self-hosted Prefect server and a worker.
helm repo add prefect https://prefecthq.github.io/prefect-helm
helm repo update
Create a new namespace for this tutorial (all commands will use this namespace):
kubectl create namespace prefect
kubectl config set-context --current --namespace=prefect
server:
basicAuth:
enabled: true
existingSecret: server-auth-secret
kubectl create secret generic server-auth-secret \
--namespace prefect --from-literal auth-string='admin:password123'
helm install prefect-server prefect/prefect-server \
--namespace prefect \
-f server-values.yaml
Expected output:
NAME: prefect-server
LAST DEPLOYED: Tue Mar 4 09:08:07 2025
NAMESPACE: prefect
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Run the following command to port-forward the UI to your localhost:
$ kubectl --namespace prefect port-forward svc/prefect-server 4200:4200
Visit http://localhost:4200 to use Prefect!
kubectl --namespace prefect port-forward svc/prefect-server 4200:4200
Open localhost:4200 in your browser. If using basic authentication, sign in with admin:password123.
To connect a worker to your self-hosted Prefect server in the same cluster:
<Expandable title="Deploy with the minimum required values"> Create a `worker-values.yaml` file for the worker (see [values.yaml template](https://github.com/PrefectHQ/prefect-helm/blob/main/charts/prefect-worker/values.yaml)):worker:
apiConfig: selfHostedServer
config:
workPool: kube-test
selfHostedServerApiConfig:
apiUrl: http://prefect-server.prefect.svc.cluster.local:4200/api
helm install prefect-worker prefect/prefect-worker \
--namespace prefect \
-f worker-values.yaml
worker:
apiConfig: selfHostedServer
config:
workPool: kube-test
selfHostedServerApiConfig:
apiUrl: http://prefect-server.prefect.svc.cluster.local:4200/api
basicAuth:
enabled: true
existingSecret: worker-auth-secret
kubectl create secret generic worker-auth-secret \
--namespace prefect --from-literal auth-string='admin:password123'
helm install prefect-worker prefect/prefect-worker \
--namespace prefect \
-f worker-values.yaml
Expected output:
Release "prefect-worker" has been installed. Happy Helming!
NAME: prefect-worker
LAST DEPLOYED: Tue Mar 4 11:26:21 2025
NAMESPACE: prefect
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
To uninstall the self-hosted Prefect server and Prefect worker:
helm uninstall prefect-worker
helm uninstall prefect-server
The Prefect server exposes two HTTP endpoints for monitoring:
| Endpoint | Checks | Typical HTTP status |
|---|---|---|
/api/health | HTTP server is running | 200 when the process is up |
/api/ready | Database connectivity | 200 when Postgres is reachable; 503 when it is not |
The prefect-server Helm chart supports optional liveness and readiness probes, but both are disabled by default. Enable them in your server values:
server:
livenessProbe:
enabled: true
readinessProbe:
enabled: true
When enabled, the liveness probe uses /api/health and the readiness probe uses /api/ready. Kubernetes then stops routing traffic when the database is down, but it does not restart the pod. If the server does not recover after Postgres becomes available, restart it manually.
If you need the pod to restart after sustained database failure, point the liveness probe at /api/ready instead. Be aware that transient database blips can trigger restarts, so tune periodSeconds and failureThreshold accordingly.
For load balancer and reverse-proxy health checks, see Load balancer configuration in the self-hosted guide.
kubectl describe pod <prefect-server-pod>.kubectl exec -it <pod> -- curl -s -o /dev/null -w "%{http_code}" localhost:4200/api/ready.kubectl rollout restart deployment/prefect-server./api/ready for liveness if automatic restart after DB outages is required (see Kubernetes health and readiness probes).
</Expandable>
Run kubectl events and confirm that the authString is correct.
</Expandable>
Ensure basicAuth is configured in the worker-values.yaml file.
</Expandable>
Ensure the PREFECT_API_URL environment variable is properly templated by running the following command:
helm template prefect-worker prefect/prefect-worker -f worker-values.yaml
The URL format should look like the following:
http://prefect-server.prefect.svc.cluster.local:4200/api
For additional troubleshooting and configuration, review the Prefect Worker Helm Chart. </Expandable>