Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit 035852e

Browse files
committed
add timescale migration & clean up postgres stuff
1 parent 3706fa9 commit 035852e

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Migrating data from TimescaleDB
3+
description: Learn how to migrate data from the TimescaleDB to a PostgreSQL
4+
instance.
5+
---
6+
7+
## Background
8+
9+
By default, Coder will deploy a Timescale database within the installation's
10+
Kubernetes namespace. We recommend using this database _only_ for evaluation
11+
purposes. With this in mind, you might want to migrate the data stored in your
12+
Timescale instance over to an out-of-cluster PostgreSQL database
13+
14+
**Note**: The following steps require Kubernetes cluster-admin access.
15+
16+
## Migration Steps
17+
18+
1. Access the timescale pod and dump the database into a file:
19+
20+
```console
21+
kubectl exec -it statefulset/timescale -n coder -- pg_dump -U coder -d coder > backup.sql
22+
```
23+
24+
> If your database is large, you can truncate Coder's telemetry, metrics, and
25+
> audit log to reduce the file size.
26+
27+
1. Access your PostgreSQL instance and create user `coder`
28+
29+
1. Import the data into your database:
30+
31+
``` console
32+
cat backup.sql > psql -U coder
33+
```
34+
35+
1. Connect your Coder instance to the database:
36+
37+
```console
38+
helm upgrade -n coder coder coder/coder \
39+
--set postgres.default.enable=false \
40+
--set postgres.host=<HOST_ADDRESS> \
41+
--set postgres.port=<PORT_NUMBER> \
42+
--set postgres.user=<DATABASE_USER> \
43+
--set postgres.database=<DATABASE_NAME> \
44+
--set postgres.passwordSecret=<secret-name> \
45+
--set postgres.sslMode=require
46+
```
47+
48+
1. (Optional) If you'd like to delete the Timescale persistent volume, run:
49+
50+
```console
51+
kubectl delete pvc timescale-data-timescale-0 -n coder
52+
```
53+
54+
At this point, you should be able to successfully login to your Coder deployment.

guides/deployments/postgres.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ streamline maintenance operations, such as backups and upgrades. The database
1616
state is _not_ backed up and will be lost when deleting the Kubernetes namespace
1717
or cluster.
1818

19+
## Configuration steps
20+
1921
> For optimal performance, it is important to ensure that the round-trip latency
2022
> between the Coder control plane services and the database is low. We recommend
2123
> ensuring that the database is within the same data center as the control

setup/installation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ kubectl config set-context --current --namespace=coder
8484

8585
```yaml
8686
postgres:
87-
useDefault: false
87+
default:
88+
enable: false
8889
host: HOST_ADDRESS
8990
port: PORT_NUMBER
9091
user: YOUR_USER_NAME

0 commit comments

Comments
 (0)