Skip to content

Commit 3122d9e

Browse files
ericpaulsenKatie Horne
and
Katie Horne
authored
feat: connecting an external postgres (#302)
* feat: connecting an external postgres * Edit text * Update secret create instructions in install * Update manifest.json * add link to guide Co-authored-by: Katie Horne <katie@coder.com>
1 parent a572e15 commit 3122d9e

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

guides/deployments/postgres.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: "PostgreSQL"
3+
description: "Learn how connect Coder to an external postgreSQL database."
4+
---
5+
6+
This guide walks you through deploying Coder with an external PostgreSQL
7+
database.
8+
9+
## Background
10+
11+
By default, Coder deploys a [TimescaleDB](https://www.timescale.com) inside the
12+
Kubernetes cluster to which you've installed Coder. However, we recommend this
13+
**only for evaluation purposes**, since the database isn't backed up and can be
14+
lost if the cluster goes down.
15+
16+
As such, we strongly recommend using a PostgreSQL database for production
17+
deployments and hosting it **outside** the Kubernetes cluster hosting Coder.
18+
19+
1. Set up a PostgreSQL instance (if you don't already have one that you can use
20+
with Coder). How you can do this depends on your cloud provider, but the
21+
following resources are good starting points:
22+
23+
- [Amazon Relational Database Service (RDS) backup & restore using AWS
24+
Backup](https://aws.amazon.com/getting-started/hands-on/amazon-rds-backup-restore-using-aws-backup)
25+
- [Quickstart: Create an Azure Database for PostgreSQL server by using the
26+
Azure
27+
portal](https://docs.microsoft.com/en-us/azure/postgresql/quickstart-create-server-database-portal)
28+
- [Deploying highly available PostgreSQL with
29+
GKE](https://cloud.google.com/architecture/deploying-highly-available-postgresql-with-gke)
30+
31+
1. Configure a private IP address for use with your PostgreSQL instance (you'll
32+
need to refer to this IP address in your [Helm
33+
chart](../admin/helm-charts.md)).
34+
35+
1. If your PostgreSQL instance requires a password, open the terminal, connect
36+
to your cluster, and create a secret for the password:
37+
38+
```console
39+
kubectl create secret generic <NAME> --from-file=test=/dev/stdin
40+
```
41+
42+
1. Get the port number for your PostgreSQL instance:
43+
44+
```sql
45+
SELECT *
46+
FROM pg_settings
47+
WHERE name = 'port';
48+
```
49+
50+
1. Get the user of the PostgreSQL instance:
51+
52+
```sql
53+
\du
54+
```
55+
56+
1. Get the name of the database *within* your PostgreSQL instance in which
57+
you're currently working:
58+
59+
```sql
60+
SELECT current_database();
61+
```
62+
63+
1. Get the name of the secret you created for your PostgreSQL instance's
64+
password:
65+
66+
```console
67+
kubectl get secrets -n <your-coder-namespace>
68+
```
69+
70+
At this point, you can [modify your Helm chart](../admin/helm-charts.md) to
71+
include the database name, port number, user, and password secret that you
72+
identified in the previous steps (these values are required to connect to your
73+
PostgreSQL instance):
74+
75+
```yaml
76+
postgres:
77+
useDefault: false
78+
host: "<your-postgres-private-ip>"
79+
port: "<your-postgres-port>"
80+
user: "<your-postgres-user>"
81+
database: "<your-db-name>"
82+
passwordSecret: "<your-postgres-secret-name>"
83+
```
84+
85+
At this point, you can install/upgrade your Coder instance using the updated
86+
Helm chart.
87+
88+
To install Coder:
89+
90+
```console
91+
helm install coder coder/coder -n <your-coder-namespace> --version=<VERSION> -f current-values.yml
92+
```
93+
94+
To upgrade Coder:
95+
96+
```console
97+
helm upgrade coder coder/coder -n <your-coder-namespace> --version=<VERSION> -f current-values.yml
98+
```
99+
100+
If this process is successful, you'll be able to access Coder using the external
101+
IP address of the ingress controller in your cluster.

manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@
300300
},
301301
{
302302
"path": "./guides/deployments/teardown.md"
303+
},
304+
{
305+
"path": "./guides/deployments/postgres.md"
303306
}
304307
]
305308
},

setup/installation.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ kubectl config set-context --current --namespace=coder
8686
```
8787
8888
To create the `passwordSecret`, run
89-
`kubectl create secret generic secret-name --from-literal=password=UserDefinedPassword`
89+
`kubectl create secret generic <NAME> --from-file=test=/dev/stdin`
9090
(be sure to replace `UserDefinedPassword` with your actual password).
9191

9292
You can find/define these values in your
9393
[PostgreSQL server configuration file](https://www.postgresql.org/docs/current/config-setting.html).
9494

95+
> For more information, [see our guide](../guides/deployments/postgres.md) on
96+
setting up a PostgreSQL instance.
97+
9598
1. [Enable dev URL usage](../admin/devurls.md). Dev URLs allow users to access
9699
the web servers running in your workspace. To enable, provide a wildcard
97100
domain and its DNS certificate and update your helm chart accordingly. This

0 commit comments

Comments
 (0)