Skip to content

Commit f00ea8a

Browse files
committed
ops: Creating Chart. Added postgres
1 parent 86a9a72 commit f00ea8a

File tree

9 files changed

+107
-16
lines changed

9 files changed

+107
-16
lines changed

deployment/kubernetes/charts/medcat-trainer-helm/Chart.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@ dependencies:
22
- name: solr
33
repository: oci://registry-1.docker.io/bitnamicharts
44
version: 9.6.10
5-
digest: sha256:f62be9fbd53de5aebf148b21c3ce7ff568a4d196f77f99a14c1207755d55e0e5
6-
generated: "2025-09-08T10:31:52.835071366Z"
5+
- name: postgresql
6+
repository: oci://registry-1.docker.io/bitnamicharts
7+
version: 16.7.27
8+
digest: sha256:a02db326b15b24d92e4c0787792803d7b224babd4f288e28a73d66a7d4506a70
9+
generated: "2025-09-10T11:29:31.705470067Z"

deployment/kubernetes/charts/medcat-trainer-helm/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ dependencies:
2828
- name: solr
2929
version: "9.6.10"
3030
repository: "oci://registry-1.docker.io/bitnamicharts"
31+
- name: postgresql
32+
version: 16.7.27
33+
repository: "oci://registry-1.docker.io/bitnamicharts"
34+
condition: postgresql.enabled
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# MedCAT Trainer Helm Chart
2+
3+
This Helm chart deploys MedCAT Trainer and infrastructure to a Kubernetes cluster.
4+
5+
By default the chart will:
6+
7+
- Run MedCAT Trainer Django server
8+
- Run NGINX for static site hosting and routing
9+
- Run a SOLR and Zookeeper cluster for the Concept DB
10+
- Run a Postgres database for persistence
11+
12+
13+
## Installation
14+
15+
```sh
16+
helm install my-medcat-trainer oci://registry-1.docker.io/cogstacksystems/medcat-trainer-helm
17+
```
18+
19+
## Configuration
20+
21+
See these values for common configurations to change:
22+
23+
| Setting |description |
24+
| -------- | -------- |
25+
| `env` | Environment variables as defined in the [MedCAT Trainer docs](https://docs.cogstack.org/projects/medcat-trainer/en/latest/installation.html). |
26+
|`medcatConfig`|MedCAT config file as described [here](https://github.com/CogStack/cogstack-nlp/blob/main/medcat-v2/medcat/config/config.py)|
27+
28+
### Use Sqlite instead of Postgres
29+
30+
Sqlite can be used for smaller single instance deployments
31+
32+
Set these values:
33+
34+
```yaml
35+
DB_ENGINE: "sqlite3"
36+
37+
postgresql:
38+
enabled: false
39+
```
40+
41+
### Missing features
42+
These features are not yet existing but to be added in future:
43+
- Use a pre existing postgres db
44+
- Use a pre existing SOLR instnace
45+
- Migrate from supervisord to standalone pods for background tasks for scaling purposes

deployment/kubernetes/charts/medcat-trainer-helm/templates/medcat-trainer-deployment.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ spec:
5454
envFrom:
5555
- configMapRef:
5656
name: {{ include "medcat-trainer-helm.fullname" . }}-medcat-trainer-env
57+
{{- if .Values.postgresql.enabled }}
58+
env:
59+
- name: DB_HOST
60+
value: {{ .Release.Name }}-postgresql
61+
- name: DB_PASSWORD
62+
valueFrom:
63+
secretKeyRef:
64+
name: {{ .Release.Name }}-postgresql
65+
key: postgres-password
66+
{{- end }}
5767
{{- with .Values.livenessProbe }}
5868
livenessProbe:
5969
{{- toYaml . | nindent 12 }}

deployment/kubernetes/charts/medcat-trainer-helm/templates/nginx-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ data:
171171
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
172172
}
173173
174-
location /healthz {
174+
location /nginx/health/live {
175175
access_log off;
176176
return 200 'OK';
177177
add_header Content-Type text/plain;

deployment/kubernetes/charts/medcat-trainer-helm/templates/nginx-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
app.kubernetes.io/component: nginx
88
spec:
99
{{- if not .Values.autoscaling.enabled }}
10-
replicas: {{ .Values.replicaCount }}
10+
replicas: {{ .Values.nginxReplicaCount }}
1111
{{- end }}
1212
selector:
1313
matchLabels:

deployment/kubernetes/charts/medcat-trainer-helm/templates/pvc.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
requests:
3333
storage: {{.Values.persistence.static.size}}
3434
---
35-
#TODO - only create if type using is sqlite
35+
{{- if eq .Values.DB_ENGINE "sqlite3" }}
3636
apiVersion: v1
3737
kind: PersistentVolumeClaim
3838
metadata:
@@ -49,8 +49,9 @@ spec:
4949
resources:
5050
requests:
5151
storage: {{.Values.persistence.sqlite.size}}
52+
{{- end }}
5253
---
53-
#TODO - only create if type using is sqlite
54+
{{- if eq .Values.DB_ENGINE "sqlite3" }}
5455
apiVersion: v1
5556
kind: PersistentVolumeClaim
5657
metadata:
@@ -66,4 +67,5 @@ spec:
6667
- ReadWriteOnce
6768
resources:
6869
requests:
69-
storage: {{.Values.persistence.sqlite.backupDbSize}}
70+
storage: {{.Values.persistence.sqlite.backupDbSize}}
71+
{{- end }}

deployment/kubernetes/charts/medcat-trainer-helm/values.yaml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
66
replicaCount: 1
7+
nginxReplicaCount: 3
78

89
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
910
image:
@@ -20,7 +21,6 @@ nginxImage:
2021
# Add any environment variables here that should be set in the medcat-trainer container
2122
env:
2223
CSRF_TRUSTED_ORIGINS: "http://localhost:8000"
23-
DB_ENGINE: "sqlite3"
2424
DEBUG: "1"
2525
EMAIL_HOST: "mail.cogstack.org"
2626
EMAIL_PASS: "to-be-changed"
@@ -35,7 +35,27 @@ env:
3535
RESUBMIT_ALL_ON_STARTUP: "0"
3636
UNIQUE_DOC_NAMES_IN_DATASETS: "True"
3737

38-
38+
# TODO: Support custom DB overrides#
39+
# DB_ENGINE: "sqlite3"
40+
DB_ENGINE: "postgresql"
41+
DB_NAME: "postgres"
42+
DB_USER: "postgres"
43+
DB_PORT: "5432"
44+
# DB_PASSWORD: ""
45+
# DB_HOST: ""
46+
47+
postgresql:
48+
enabled: true
49+
# TODO: Support custom DB overrides
50+
# auth:
51+
# - name for a custom database
52+
# database: "my_trainer_db"
53+
# username: "trainer_admin"
54+
# password: "changeme_changeme"
55+
primary:
56+
persistence:
57+
# Size of the PVC for the postgres database
58+
size: 500Mi
3959
persistence:
4060
media:
4161
# Size of PVC for files like model packs and other media downloaded by medcat trainer
@@ -49,8 +69,7 @@ persistence:
4969
# Size of the PVC for the Sqlite backups
5070
backupDbSize: 300Mi
5171
storageClassName: ""
52-
# Engine can be 'sqlite3' or 'postgresql'
53-
dbEngine: sqlite3
72+
5473

5574
# MedCAT config as described here: https://github.com/CogStack/cogstack-nlp/blob/main/medcat-v2/medcat/config/config.py
5675
medcatConfig: |
@@ -160,22 +179,30 @@ resources: {}
160179

161180
# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
162181
# TODO Add liveness and readiness to django app
182+
# https://github.com/CogStack/cogstack-nlp/pull/131/files
163183
# livenessProbe:
164184
# httpGet:
165-
# path: /
185+
# path: /api/health/live/
166186
# port: http
167187
# readinessProbe:
168188
# httpGet:
169-
# path: /
189+
# path: /api/health/ready/
170190
# port: http
191+
# startupProbe:
192+
# httpGet:
193+
# path: /api/health/startup/
194+
# port: http
195+
# failureThreshold: 30
196+
# periodSeconds: 10
197+
171198
nginx:
172199
livenessProbe:
173200
httpGet:
174-
path: /healthz
201+
path: /nginx/health/live
175202
port: http
176203
readinessProbe:
177204
httpGet:
178-
path: /healthz
205+
path: /nginx/health/live
179206
port: http
180207

181208

deployment/kubernetes/local_dev_startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ helm test medcat-service --logs
2121
# Test medcat trainer
2222
# kubectl port-forward svc/nginx 8000:8000
2323

24-
helm upgrade medcat-trainer ./medcat-trainer-helm --install --recreate-pods --wait --timeout 5m0s # Install if it doesnt already exist, else upgrade
24+
helm upgrade my-test ./medcat-trainer-helm --install --recreate-pods --wait --timeout 5m0s # Install if it doesnt already exist, else upgrade
2525
# kubectl port-forward svc/medcat-trainer-solr 8983:8983

0 commit comments

Comments
 (0)