Skip to content

Commit

Permalink
Add PostgreSQL DB relation (#32)
Browse files Browse the repository at this point in the history
* add postgresql db relation
  • Loading branch information
kelkawi-a authored Dec 5, 2024
1 parent f8d1235 commit b7e9ac2
Show file tree
Hide file tree
Showing 23 changed files with 4,391 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
secrets: inherit
with:
channel: 1.25-strict/stable
modules: '["test_charm.py", "test_scaling.py", "test_vault.py"]'
modules: '["test_charm.py", "test_scaling.py", "test_vault.py", "test_postgres_db.py"]'
juju-channel: 3.4/stable
self-hosted-runner: false
microk8s-addons: "dns ingress rbac storage metallb:10.15.119.2-10.15.119.4 registry"
3 changes: 3 additions & 0 deletions .woke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules:
# Ignore "master" - the database relation event received from the library.
- name: master
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,32 @@ compatibility issues with some versions of Juju (e.g. Juju `v3.2.4`). It has
been tested successfully with Juju
[`v3.3.5`](https://github.com/canonical/temporal-worker-k8s-operator/actions/runs/9874524137/job/27269330380).

## PostgreSQL

The Charmed Temporal Worker can be related to the
[PostgreSQL operator charm](https://charmhub.io/postgresql-k8s) to enable the
creation of a database to be used by your workflows. To enable this, run the
following commands:

```bash
juju deploy postgresql-k8s --channel 14/stable --trust
juju relate temporal-worker-k8s postgresql-k8s
```

Once this is done and all units are settled and active, you can refer to the
database credentials within your workflow code using the following environment
variables:

- `TEMPORAL_DB_NAME`
- `TEMPORAL_DB_HOST`
- `TEMPORAL_DB_PORT`
- `TEMPORAL_DB_USER`
- `TEMPORAL_DB_PASSWORD`
- `TEMPORAL_DB_TLS`

An example of this can be found in the
[`db_activity`](./resource_sample_py/resource_sample/activities/db_activity.py).

## Contributing

This charm is still in active development. Please see the
Expand Down
5 changes: 5 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ options:
default: ""
type: string

db-name:
description: Name of the database created when relating to a database charm.
default: ""
type: string

environment:
description: |
This configuration is used to manage and retrieve sensitive information required
Expand Down
Loading

0 comments on commit b7e9ac2

Please sign in to comment.