Nicolas May
07/28/2022, 1:37 PMdagster.yaml
(https://docs.dagster.io/deployment/dagster-instance#postgres-storage) or in the dagster_postgres
source (https://docs.dagster.io/_modules/dagster_postgres/event_log/event_log#PostgresEventLogStorage).
Many thanks for any help!Nicolas May
07/28/2022, 1:55 PMdagster.yaml
accepts Postgres connection stringmarcos
07/28/2022, 2:08 PMNicolas May
07/28/2022, 2:08 PMmarcos
07/28/2022, 2:14 PMmarcos
07/28/2022, 2:16 PMNicolas May
07/28/2022, 2:16 PMmarcos
07/28/2022, 2:17 PMNicolas May
07/28/2022, 2:18 PMNicolas May
07/28/2022, 2:25 PMdagster.yaml
like...
storage:
postgres:
postgres_url: <postgresql://user:pass@10.0.0.1:5432/mydatabase?sslmode=verify-ca&sslrootcert=server-ca.pem&sslcert=client-cert.pem&sslkey=client-key.pem>
... but obvi pulling the conn url from env:
.env
PG_DB_CONN_STRING=<postgresql://user:pass@10.0.0.1:5432/mydatabase?sslmode=verify-ca&sslrootcert=server-ca.pem&sslcert=client-cert.pem&sslkey=client-key.pem>
dagster.yaml
storage:
postgres:
postgres_url:
env: PG_DB_CONN_STRING
marcos
07/28/2022, 2:40 PMNicolas May
07/28/2022, 2:41 PMNicolas May
07/28/2022, 2:42 PMNicolas May
07/28/2022, 4:38 PMmarcos
07/28/2022, 4:47 PMyuhan
07/28/2022, 5:19 PMNicolas May
07/28/2022, 7:28 PMdocker-compose.yaml
services have bind mounts to the certs directory.
For example:
docker_dagit:
image: us-central1-docker.pkg.dev/project-foo/foo/dagster_multi_container_docker_dagit
container_name: docker_dagit
entrypoint:
- dagit
- -h
- "0.0.0.0"
- -p
- "3000"
- -w
- workspace.yaml
expose:
- "3000"
ports:
- "3000:3000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /tmp/io_manager_storage:/tmp/io_manager_storage
- type: bind ### <-- HERE
source: /host/path/to/certs ### <-- HERE
target: /container/path/to/certs/ ### <-- HERE
environment:
DAGSTER_POSTGRES_HOST: "${DAGSTER_POSTGRES_HOST}"
DAGSTER_POSTGRES_DB: "${DAGSTER_POSTGRES_DB}"
DAGSTER_POSTGRES_USER: "${DAGSTER_POSTGRES_USER}"
DAGSTER_POSTGRES_PASSWORD: "${DAGSTER_POSTGRES_PASSWORD}"
PG_DB_CONN_STRING: "${PG_DB_CONN_STRING}" ### <-- HERE
networks:
- docker_network
depends_on:
- docker_example_user_code
^^^ Also do the above for dagster-daemon service.
(2) Also notice that the docker-compose service above has a new env var PG_DB_CONN_STRING
, which is passed from the .env
file. All the services have this env var defined as PG_DB_CONN_STRING: "${PG_DB_CONN_STRING}"
. I still have to clean up the environment variables here.
(3a) dagster.yaml
- run_launcher
needs two things: (a) the PG_DB_CONN_STRING
passed to env_vars
config, (b) a volume map to the dir that contains the certs, like /host/path/to/certs/:/container/path/to/certs
. If this isn't updated, the containerized runs just freeze... no errors as far as I could tell.
For example:
run_launcher:
module: dagster_docker
class: DockerRunLauncher
config:
env_vars:
#- DAGSTER_POSTGRES_HOST
#- DAGSTER_POSTGRES_DB
#- DAGSTER_POSTGRES_USER
#- DAGSTER_POSTGRES_PASSWORD
- PG_DB_CONN_STRING ### <-- HERE
network: docker_network
container_kwargs:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /tmp/io_manager_storage:/tmp/io_manager_storage
- /host/path/to/certs:/container/path/to/certs ### <-- HERE
(3b) dagster-compose.yaml
- storage
needs to be updated. You can get rid of all the DAGSTER_POSTGRES_*
stuff.
storage:
postgres:
postgres_url:
env: PG_DB_CONN_STRING
(4) .env
on the VM needs to be updated to include PG_DB_CONN_STRING
PG_DB_CONN_STRING=<postgresql://user:pass@10.0.0.1:5432/mydatabase?sslmode=verify-ca&sslrootcert=/container/path/to/certs/server-ca.pem&sslcert=/container/path/to/certs/client-cert.pem&sslkey=/container/path-to/certs/client-key.pem>
I believe that's all of it. Keep me posted if you're so inclined.