We use cookies to make your experience better.
Learn how connect Coder to an external postgreSQL database.
This guide walks you through deploying Coder with an external PostgreSQL database.
By default, Coder deploys a TimescaleDB inside the Kubernetes cluster to which you've installed Coder. However, we recommend this only for evaluation purposes, since the database isn't backed up and can be lost if the cluster goes down.
As such, we strongly recommend using a PostgreSQL database for production deployments and hosting it outside the Kubernetes cluster hosting Coder.
Set up a PostgreSQL instance (if you don't already have one that you can use with Coder). How you can do this depends on your cloud provider, but the following resources are good starting points:
Configure a private IP address for use with your PostgreSQL instance (you'll need to refer to this IP address in your Helm chart).
If your PostgreSQL instance requires a password, open the terminal, connect to your cluster, and create a secret for the password:
kubectl create secret generic <NAME> --from-file=test=/dev/stdin
Get the port number for your PostgreSQL instance:
SELECT *
FROM pg_settings
WHERE name = 'port';
Get the user of the PostgreSQL instance:
\du
Get the name of the database within your PostgreSQL instance in which you're currently working:
SELECT current_database();
Get the name of the secret you created for your PostgreSQL instance's password:
kubectl get secrets -n <your-coder-namespace>
At this point, you can modify your Helm chart to include the database name, port number, user, and password secret that you identified in the previous steps (these values are required to connect to your PostgreSQL instance):
postgres:
useDefault: false
host: "<your-postgres-private-ip>"
port: "<your-postgres-port>"
user: "<your-postgres-user>"
database: "<your-db-name>"
passwordSecret: "<your-postgres-secret-name>"
At this point, you can install/upgrade your Coder instance using the updated Helm chart.
To install Coder:
helm install coder coder/coder -n <your-coder-namespace> --version=<VERSION> -f current-values.yml
To upgrade Coder:
helm upgrade coder coder/coder -n <your-coder-namespace> --version=<VERSION> -f current-values.yml
If this process is successful, you'll be able to access Coder using the external IP address of the ingress controller in your cluster.
Our docs are open source. See something wrong or unclear? Make an edit.