CHT Core Framework > Overview > CHT Core
The different pieces of a CHT project, how they interact, and what they’re used for
We recommend running CHT Sync in production using Kubernetes. This guide will walk you through setting up a production deployment of CHT Sync with the CHT using Kubernetes.
The disk space required for the database depends on a few things including the size the of CouchDB databases being replicated, and the models defined. The database will grow over time as more data is added to CouchDB. The database should be monitored to ensure that it has enough space to accommodate the data. To get an idea of the size requirements of the database, you can replicate 10% of the data from CouchDB to Postgres and then run the following command to see disk usage:
SELECT pg_size_pretty(pg_database_size('your_database_name'));
If Postgres is running in a Kubernetes cluster, you can use the following command to get the disk usage:
kubectl exec -it postgres-pod-name -- psql -U postgres -c "SELECT pg_size_pretty(pg_database_size('your_database_name'));"
You can then multiply this figure by 10 to get an estimate of the disk space required for the full dataset and then add some extra space for indexes and other overhead as well as future growth.
For example if the size of the database is 1GB, you can expect the full dataset to be around 10GB. If the CouchDB docs grow by 20% every year then you can compound this growth over 5 years to get an estimate of the disk space required: 10GB * 1.2^5 = 18.5GB
. You can add an extra 20% for indexes and overhead to get an estimate of 22.2GB.
Please note that this is just an estimate and the actual disk space required may vary so actively monitoring the disk space usage and making necessary adjustments is recommended.
git
, clone the CHT Sync repository from GitHub: git clone https://github.com/medic/cht-sync.git
cht-sync
folder, copy the values in deploy/cht_sync/values.yaml.template
file to a new file named deploy/cht_sync/values.yaml
.postgres.enabled
flag in the values.yaml
file. If you already have a Postgres database outside the cluster, you can set the postgres.enabled
flag to false
.host
and port
in this sectionuser
, password
, db
, schema
, and table
schema
can be used to separate CHT models from any other data that may already be in the databasetable
is the name of the table that couch2pg will write couch documents to, and the source table for dbt models. It is recommended to leave this as couchdb
.postgres:
enabled: true
user: "postgres"
password: ""
db: ""
schema: "v1"
table: "couchdb"
values.yaml
file.couchdb:
user: "your_couchdb_user"
dbs: "medic"
port: "443"
secure: "true"
values.yaml
file. For the host, use the CouchDB host URL used to publicly access the instance and for the password, use the password associated with the user set above.couchdbs:
- host: "host1.cht-core.test"
password: "password1"
couchdbs
list.couchdbs:
- host: "host1.cht-core.test"
password: "password1"
- host: "host2.cht-core.test"
password: "password2"
couchdbs
list. - host: "host1" # required for all couchdb instances
password: "" # required for all couchdb instances
- host: "host2.cht-core.test"
password: "new_password"
user: "separate_user"
dbs: "medic medic_sentinel"
port: "5984"
secure: "false"
- host: "host3.cht-core.test"
password: "password3"
values.yaml
file.cht_pipeline_branch_url: "https://github.com/medic/cht-pipeline.git#main"
metrics
at port 9399, for use with CHT Watchdog or any other monitoring service.
An HTTP ingress needs to be created to allow access from outside the cluster.metrics_exporter:
enabled: true
Run the command below to deploy the cht-sync helm chart. The chart is at deploy/cht_sync
, if values.yaml is in a different directory, specify the path.
cd deploy/cht_sync
helm install cht-sync . --values values.yaml
Run the following command to get the status of the deployment.
kubectl get pods
Run the following command to get the logs of a pod.
kubectl logs -f cht-sync-<pod-id>
The different pieces of a CHT project, how they interact, and what they’re used for
Data synchronization tools to enable analytics
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.