When deploy Prefect Server into Kubernetes by Helm Chart, I can disable default Postgres by changing
to
postgresql:
enabled: false
Next step, I am trying to point to a existing Postgres, however, I didn’t find any info in the Helm chart.
Any guide would be appreciate. Thanks! 
Hey Hongbo, the field postgresql.externalHostname
is used to define the hostname for your external postgres database, then set postgresql to disabled and fill in all of the credential fields.
Thanks @George_Coyne !
For example, I have a database at http://postgres-service.hm-postgres.svc:5432
.
I tried
helm install \
prefect-server \
prefect/prefect-server \
--namespace=hm-prefect \
--create-namespace \
--values=my-values.yaml
my-values.yaml
server:
publicApiUrl: https://xxx.com/api
postgresql:
enabled: false
auth:
username: admin
password: passw0rd
externalHostname: postgres-service.hm-postgres.svc
I did set enabled: false
, but Prefect Server helm chart still created a Postgres.
Any idea? Thanks!
I believe you want:
postgresql:
useSubChart: false
instead of enabled: false
.
This isn’t clear in the current prefect-helm default values, could definitely do with an update. There’s a comment about it here though: server/values.yaml at master · PrefectHQ/server · GitHub
1 Like
Thanks @George_Coyne and @jwlarocque !
The helm values are quite confused, it turns out I actually only need set two values:
Here is my final solution to use external Postgres host.
Assuming my Postgres host is postgres-service.hm-postgres.svc
, port is 5432
, username is admin
, password is passw0rd
.
First, I need create a secret, and this secret has to be in same namespace with Prefect Server.
kubectl create secret generic hm-prefect-postgres-secret \
--namespace=hm-prefect \
--from-literal="connection-string=postgresql+asyncpg://admin:passw0rd@postgres-service.hm-postgres.svc:5432/hm_prefect_db"
Then, I can deploy Prefect Server by:
helm install \
prefect-server \
prefect/prefect-server \
--namespace=hm-prefect \
--create-namespace \
--values=my-values.yaml
my-values.yaml
server:
publicApiUrl: https://prefect.example.com/api
postgresql:
useSubChart: false
auth:
existingSecret: hm-prefect-postgres-secret
Hopefully it helps save people some time in future! 