<@ULVA73B9P> I’m setting up Prefect via Helm and ...
# marvin-in-the-wild
m
@Marvin I’m setting up Prefect via Helm and deploying to EKS cluster. I want to use external DB - RDS Postgres. Can you provide the steps/config?
m
To set up Prefect with Helm on an EKS cluster and use an external RDS Postgres database, follow these steps: 1. Add the Prefect Helm Repository:
Copy code
sh
   helm repo add prefect <https://prefecthq.github.io/prefect-helm>
   helm repo update
2. Create a Namespace:
Copy code
sh
   kubectl create namespace prefect
3. Create a Kubernetes Secret for the Prefect API Key:
Copy code
sh
   kubectl create secret generic prefect-api-key \
   --namespace=prefect --from-literal=key=YOUR_PREFECT_CLOUD_API_KEY
4. Configure Helm Chart Values: Create a
values.yaml
file to set up your specific configurations including the external Postgres database. Here is an example content for the
values.yaml
file:
Copy code
yaml
   database:
     enabled: false  # Disable the default Prefect database

   externalDatabase:
     connectionUrl: "<postgresql+asyncpg://USERNAME:PASSWORD@RDS_ENDPOINT:PORT/DATABASE_NAME>"
Replace
USERNAME
,
PASSWORD
,
RDS_ENDPOINT
,
PORT
, and
DATABASE_NAME
with your actual RDS Postgres details. 5. Install Prefect with Helm:
Copy code
sh
   helm install prefect prefect/prefect -n prefect -f values.yaml
For further details, refer to the Prefect Kubernetes Deployment Guide for more in-depth instructions and configurations. If you need to adjust Postgres-specific settings, consult the Prefect DB Configuration Guide. Feel free to ask for more details or additional assistance on specific points!
m
So the latest values looks a little different. I’ve used this postgresql: enabled: false auth: existingSecret: prefect database: prefect username: prefect externalHostname: “prefect.blahblah.us-west-2.rds.amazonaws.com” The secret has 2 key-value pairs as stated in docs Got no_hba.conf entry for host error in server @Marvin
m
The "no_hba.conf entry for host" error on your PostgreSQL server indicates issues with host-based authentication (HBA). This usually means that the database is not allowing connections from your Prefect worker's IP addresses. To solve this, you'll need to update the
pg_hba.conf
file on your RDS Postgres instance to allow connections from your EKS cluster. Here's a step-by-step guide: 1. Find the IP range of your EKS cluster: You can usually get this from your AWS Console or by querying your EKS setup. 2. Access the RDS instance and modify the
pg_hba.conf
file:
- Log into your RDS Postgres instance. - Modify the
pg_hba.conf
file to include an entry for your EKS cluster's IP range. You'll typically find this file in the data directory of your Postgres installation. Example entry:
Copy code
host    all             all             YOUR_EKS_CLUSTER_IP_RANGE/XX     md5
3. Reload the PostgreSQL configuration: After modifying
pg_hba.conf
, you must reload the PostgreSQL configuration to apply the changes. You can do this using:
Copy code
sh
   SELECT pg_reload_conf();
4. Verify Database Settings in Your Helm Values File: Ensure your
values.yaml
correctly references the external database. Your current configuration should look similar to this:
Copy code
yaml
   postgresql:
     enabled: false
     auth:
       existingSecret: prefect
       database: prefect
       username: prefect
     externalHostname: "<http://prefect.blahblah.us-west-2.rds.amazonaws.com|prefect.blahblah.us-west-2.rds.amazonaws.com>"
5. Confirm Kubernetes Secret Configuration: Ensure your Kubernetes secret contains the correct key-value pairs:
Copy code
sh
   kubectl create secret generic prefect --namespace prefect --from-literal=username=YOUR_DB_USERNAME --from-literal=password=YOUR_DB_PASSWORD
By correctly configuring the
pg_hba.conf
file to accept connections from your EKS cluster and ensuring your Helm values and Kubernetes secrets are correctly set up, you should resolve the connection issue. For more details on connecting to external databases, you can refer to these Prefect documentation guides: - Host-based authentication - PostgreSQL configuration guide Feel free to ask if you need further assistance!