Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Commit

Permalink
fix(kubernetes): use self-configuring image
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Dec 21, 2019
1 parent eedc4a5 commit 3cdd551
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@ prune older data, compression will not be available, and queries will be slower.

## Getting Started

- run TimescaleDB somewhere, like [a Kubernetes pod](kubernetes/README.md) or [Timescale Cloud](https://www.timescale.com/cloud)
- set the `PG*` environment variables for your connection info (`PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, `PGDATABASE`)
- create a database
- run `./scripts/schema-create.sh [license-level] [retain-live] [retain-total]`
- create a role for each set of adapters to write
- run `./scripts/schema-grant.sh [role-name] adapter`
- create a role for each Grafana instance to read
- run `./scripts/schema-grant.sh [role-name] grafana`
- create a role for each human instance to read
- run `./scripts/schema-grant.sh [role-name] human`
- create the schema:
- deploy `kubernetes/server.yml`
- or `docker run --rm -p 5432:5432 ssube/prometheus-sql-adapter:master-postgres-11 -c 'shared_preload_libraries=timescaledb'`
- or run `./scripts/schema-create [license-level] [retain-live] [retain-total]` against an existing database
- configure adapters:
- create a role for each set of adapters to write
- run `./scripts/schema-grant.sh [role-name] adapter`
- deploy `kubernetes/adapter.yml`
- configure Grafana:
- create a role for each Grafana instance to read
- run `./scripts/schema-grant.sh [role-name] grafana`
- add a Postgres data source
- import dashboards from `grafana/`
- configure humans:
- create a role for each developer to read
- run `./scripts/schema-grant.sh [role-name] human`
- show off your sweet new graphs

The schema scripts are idempotent and safe to run repeatedly, including `schema-create.sh`.

Expand Down
21 changes: 11 additions & 10 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

To deploy TimescaleDB and this SQL adapter:

- create a namespace: `k create ns foo`
- create a namespace: `k create ns test-schema`
- apply node labels
- for server nodes: `k label node/bar timescale-role=server`
- for adapter nodes: `k label node/baz timescale-role=adapter`
- apply the server: `k apply -n foo -f kubernetes/server.yml`
- [get started](../README.md#getting-started)
- you may need to forward a port to the server: `k -n foo port-forward svc/timescale-server 5432:5432`
- apply the schema: `PGHOST=localhost PGUSER=your-name PGPASSWORD=very-secret ./scripts/schema-create.sh`
- create an adapter role
- for server nodes: `k label node/server timescale-role=server`
- for adapter nodes: `k label node/adapter timescale-role=adapter`
- apply the server: `k apply -n test-schema -f kubernetes/server.yml`
- create an adapter role ([getting started](../README.md#getting-started))
- `k exec -n test-schema -it timescale-server-0 -- psql -U postgres`
- `CREATE USER prometheus_adapter WITH LOGIN PASSWORD 'very-secret';`
- `k exec -n test-schema -it timescale-server-0 -- sh -c 'cd /app; PGUSER=postgres PGDATABASE=prometheus /app/scripts/schema-grant.sh prometheus_adapter adapter'`
- create a secret with PG connection info:
`k create secret generic prometheus-adapter-env -n foo --from-literal=PGUSER=adapter --from-literal=PGPASSWORD=very-secret --from-literal=PGDATABASE=bar`
`k create secret generic timescale-adapter-env -n test-schema --from-literal=PGUSER=prometheus_adapter --from-literal=PGPASSWORD=very-secret --from-literal=PGDATABASE=prometheus`
- apply the adapter: `k apply -n foo -f kubernetes/adapter.yml`

The server and two adapter pods should be `Running`:
Expand Down Expand Up @@ -40,5 +40,6 @@ level=info ts=2019-11-28T19:34:12.447Z caller=main.go:179 msg="Starting up..."

## Notes

- The server sets up the `prometheus` database and metrics schema within that when it starts up.
- The server pod does not have persistent storage, so any data will be lost when it restarts.
- The `--pg.conn-str` parameter will be printed in the logs, please put the password in the `PGPASSWORD` env var.
- The server pod does not have persistent storage, so any data (including the schema) will be lost when it restarts.
14 changes: 8 additions & 6 deletions kubernetes/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ spec:
spec:
containers:
- args:
- -c
- synchronous_commit=OFF
- -c
- synchronous_commit=OFF
- -c
- shared_preload_libraries=timescaledb
image: ssube/prometheus-sql-adapter:master-postgres-10
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
name: server
ports:
- containerPort: 5432
name: db
protocol: TCP
- containerPort: 5432
name: db
protocol: TCP
resources:
limits:
cpu: "2"
Expand Down

0 comments on commit 3cdd551

Please sign in to comment.