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
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>