From 078b5de6b9c26d6d3c60257d2adfdf9278e9aaea Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 13:37:36 +0000 Subject: [PATCH 01/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation --- .../charts/medcat-service-helm/README.md | 71 ++++++----- .../templates/deployment.yaml | 12 +- .../charts/medcat-service-helm/values.yaml | 6 + .../helm/charts/medcat-service-helm.md | 111 ++++++++++++++---- 4 files changed, 146 insertions(+), 54 deletions(-) diff --git a/deployment/kubernetes/charts/medcat-service-helm/README.md b/deployment/kubernetes/charts/medcat-service-helm/README.md index 084d30f..95c7135 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/README.md +++ b/deployment/kubernetes/charts/medcat-service-helm/README.md @@ -5,61 +5,76 @@ This Helm chart deploys the MedCAT service to a Kubernetes cluster. ## Installation ```sh -helm install my-medcat-service oci://registry-1.docker.io/cogstacksystems/medcat-service-helm +helm install medcat-service-helm oci://registry-1.docker.io/cogstacksystems/medcat-service-helm ``` +## Usage +For local testing, by default you can port forward the service using this command: + +```sh +kubectl port-forward svc/medcat-service-helm 5000:5000 +``` + +Then navigate to http://localhost:5000 to try the service. You can also use http://localhost:5000/docs to view the REST APIs + + ## Configuration +To configure medcat service, create a values.yaml file and install with helm. + +### Model Pack You should specify a model pack to be used by the service. By default it will use a small bundled model, which can be used for testing --- -### Option 1: Use the demo model pack +#### Default: Use the demo model pack There is a model pack already bundled into medcat service, and is the default in this chart. This pack is only really used for testing, and has just a few concepts built in. -### Option 2: Download Model on Startup +#### Recommended: Download Model on Startup Enable MedCAT to download the model from a remote URL on container startup. -Create a values file like `values-model-download.yaml` and update the env vars with: +Create a values file like `values-model-download.yaml` and set these values: ```yaml -env: - ENABLE_MODEL_DOWNLOAD: "true" - MODEL_NAME: "medmen" - MODEL_VOCAB_URL: "https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/vocab.dat" - MODEL_CDB_URL: "https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/cdb-medmen-v1.dat" - MODEL_META_URL: "https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/mc_status.zip" - APP_MODEL_CDB_PATH: "/cat/models/medmen/cdb.dat" +model: + downloadUrl: "http://localhost:9000/models/my-model.zip" + name: my-model.zip ``` Use this if you prefer dynamic loading of models at runtime. -### Option 3: Get a model into a k8s volume, and mount it +#### Advanced: Create a custom volume and load a model into it The service can use a model pack if you want to setup your own download flow. For example, setup an initContainer pattern that downloads to a volume, then mount the volume yourself. -Use this env variable to point to the file: +1. Create a persistent volume and PVC in kubernetes following the official documentation. Alternatively specifiy it in `values.extraManifests` and it will be created. + +2. Create a values file like the following, which mounts the volume, and defines a custom init container. -Create a values file like `values-model-pack.yaml` and update the env vars with: ```yaml env: - # This defines the Model Pack used by the medcat service - APP_MEDCAT_MODEL_PACK: "/cat/models/examples/example-medcat-v1-model-pack.zip" -``` + APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" +volumeMounts: + name: model-volume + mountPath: /my/models + +volumes: +- name: model-volume + persistentVolumeClaim: + claimName: my-custom-pvc +extraInitContainers: + - name: model-downloader + image: busybox:1.28 + # In this command, you can write custom code required to download a file. For example you could configure authentication. + command: ["sh", "-c", "wget -O /my/models/custom-model.zip http://example.com"] + volumeMounts: + - name: model-volume + mountPath: /my/models -## Example - -```sh -helm install my-medcat ./medcat-chart -f values-model-pack.yaml ``` -or - -```sh -helm install my-medcat ./medcat-chart -f values-model-download.yaml -``` ### DeID Mode @@ -73,7 +88,7 @@ env: ``` -## GPU Support +### GPU Support To run MedCAT Service with GPU acceleration, use the GPU-enabled image and set the pod runtime class accordingly. @@ -101,7 +116,7 @@ env: > - [NVIDIA GPU Feature Discovery](https://github.com/NVIDIA/gpu-feature-discovery) > - The [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/) -### Test GPU support +#### Test GPU support You can verify that the MedCAT Service pod has access to the GPU by executing `nvidia-smi` inside the pod. diff --git a/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml b/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml index 1db23b4..49983eb 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml @@ -79,15 +79,17 @@ spec: {{- if or .Values.model.downloadUrl .Values.volumeMounts }} volumeMounts: {{- if .Values.volumeMounts }} - {{- toYaml .Values.volumeMounts | nindent 2 }} + {{- toYaml .Values.volumeMounts | nindent 12 }} {{- end }} {{- if .Values.model.downloadUrl }} - name: models mountPath: /models {{- end }} {{- end }} - {{- if .Values.model.downloadUrl }} + {{- if or .Values.extraInitContainers .Values.model.downloadUrl }} initContainers: + {{- end }} + {{- if .Values.model.downloadUrl }} - name: model-downloader image: busybox:1.28 command: @@ -111,11 +113,13 @@ spec: - name: models mountPath: /models {{- end }} - + {{- with .Values.extraInitContainers }} + {{- tpl (toYaml .) . | nindent 8 }} + {{- end }} {{- if or .Values.model.downloadUrl .Values.volumes }} volumes: {{- if .Values.volumes }} - {{- toYaml .Values.volumes | nindent 2 }} + {{- toYaml .Values.volumes | nindent 8 }} {{- end }} {{- if .Values.model.downloadUrl }} - name: models diff --git a/deployment/kubernetes/charts/medcat-service-helm/values.yaml b/deployment/kubernetes/charts/medcat-service-helm/values.yaml index 4a880c9..909f632 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/values.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/values.yaml @@ -233,3 +233,9 @@ networkPolicy: # app.kubernetes.io/name: model-downloader # ports: # - port: 5000 + +# Additional init containers to run before the main container. Can be templated +extraInitContainers: [] + +# Additional manifests to deploy to kubernetes. Can be templated +extraManifests: [] \ No newline at end of file diff --git a/docs/docs/platform/deployment/helm/charts/medcat-service-helm.md b/docs/docs/platform/deployment/helm/charts/medcat-service-helm.md index 68fba10..9574261 100644 --- a/docs/docs/platform/deployment/helm/charts/medcat-service-helm.md +++ b/docs/docs/platform/deployment/helm/charts/medcat-service-helm.md @@ -5,58 +5,125 @@ This Helm chart deploys the MedCAT service to a Kubernetes cluster. ## Installation ```sh -helm install my-medcat-service oci://registry-1.docker.io/cogstacksystems/medcat-service-helm +helm install medcat-service-helm oci://registry-1.docker.io/cogstacksystems/medcat-service-helm ``` +## Usage + +For local testing, by default you can port forward the service using this command: + +```sh +kubectl port-forward svc/medcat-service-helm 5000:5000 +``` + +Then navigate to http://localhost:5000 to try the service. You can also use http://localhost:5000/docs to view the REST APIs + ## Configuration +To configure medcat service, create a values.yaml file and install with helm. + +### Model Pack + You should specify a model pack to be used by the service. By default it will use a small bundled model, which can be used for testing --- -### Option 1: Use the demo model pack + +#### Default: Use the demo model pack There is a model pack already bundled into medcat service, and is the default in this chart. -This pack is only really used for testing, and has just a few concepts built in. +This pack is only really used for testing, and has just a few concepts built in. -### Option 2: Download Model on Startup +#### Recommended: Download Model on Startup Enable MedCAT to download the model from a remote URL on container startup. -Create a values file like `values-model-download.yaml` and update the env vars with: +Create a values file like `values-model-download.yaml` and set these values: + ```yaml -env: - ENABLE_MODEL_DOWNLOAD: "true" - MODEL_NAME: "medmen" - MODEL_VOCAB_URL: "https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/vocab.dat" - MODEL_CDB_URL: "https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/cdb-medmen-v1.dat" - MODEL_META_URL: "https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/mc_status.zip" - APP_MODEL_CDB_PATH: "/cat/models/medmen/cdb.dat" +model: + downloadUrl: "http://localhost:9000/models/my-model.zip" + name: my-model.zip ``` Use this if you prefer dynamic loading of models at runtime. -### Option 3: Get a model into a k8s volume, and mount it +#### Advanced: Create a custom volume and load a model into it The service can use a model pack if you want to setup your own download flow. For example, setup an initContainer pattern that downloads to a volume, then mount the volume yourself. -Use this env variable to point to the file: +1. Create a persistent volume and PVC in kubernetes following the official documentation. Alternatively specifiy it in `values.extraManifests` and it will be created. + +2. Create a values file like the following, which mounts the volume, and defines a custom init container. -Create a values file like `values-model-pack.yaml` and update the env vars with: ```yaml env: - # This defines the Model Pack used by the medcat service - APP_MEDCAT_MODEL_PACK: "/cat/models/examples/example-medcat-v1-model-pack.zip" + APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" +volumeMounts: + name: model-volume + mountPath: /my/models + +volumes: + - name: model-volume + persistentVolumeClaim: + claimName: my-custom-pvc +extraInitContainers: + - name: model-downloader + image: busybox:1.28 + # In this command, you can write custom code required to download a file. For example you could configure authentication. + command: + ["sh", "-c", "wget -O /my/models/custom-model.zip http://example.com"] + volumeMounts: + - name: model-volume + mountPath: /my/models ``` -## Example +### DeID Mode + +The service can perform DeID of EHRs by swithcing to the following values -```sh -helm install my-medcat ./medcat-chart -f values-model-pack.yaml ``` +env: + APP_MEDCAT_MODEL_PACK: "/cat/models/examples/example-deid-model-pack.zip" + DEID_MODE: "true" + DEID_REDACT: "true" +``` + +### GPU Support + +To run MedCAT Service with GPU acceleration, use the GPU-enabled image and set the pod runtime class accordingly. + +Note GPU support is only used for deidentification + +Create a values file like `values-gpu.yaml` with the following content: + +```yaml +image: + repository: ghcr.io/cogstack/medcat-service-gpu -or +runtimeClassName: nvidia + +resources: + limits: + nvidia.com/gpu: 1 +env: + APP_CUDA_DEVICE_COUNT: 1 + APP_TORCH_THREADS: -1 + DEID_MODE: true +``` + +> To use GPU acceleration, your Kubernetes cluster should be configured with the NVIDIA GPU Operator or the following components: +> +> - [NVIDIA device plugin for Kubernetes](https://github.com/NVIDIA/k8s-device-plugin) +> - [NVIDIA GPU Feature Discovery](https://github.com/NVIDIA/gpu-feature-discovery) +> - The [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/) + +#### Test GPU support + +You can verify that the MedCAT Service pod has access to the GPU by executing `nvidia-smi` inside the pod. ```sh -helm install my-medcat ./medcat-chart -f values-model-download.yaml +kubectl exec -it -- nvidia-smi ``` + +You should see the NVIDIA GPU device listing if the GPU is properly accessible. From 312669c2cb0ccf477e147e27d68bab8ed1643c6f Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 13:44:59 +0000 Subject: [PATCH 02/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation -format --- deployment/kubernetes/charts/medcat-service-helm/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/kubernetes/charts/medcat-service-helm/values.yaml b/deployment/kubernetes/charts/medcat-service-helm/values.yaml index 909f632..2fd12f1 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/values.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/values.yaml @@ -238,4 +238,4 @@ networkPolicy: extraInitContainers: [] # Additional manifests to deploy to kubernetes. Can be templated -extraManifests: [] \ No newline at end of file +extraManifests: [] From fa506b2ab8194053a27ccdb0e26ddbd0b9b4e8ff Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 13:45:16 +0000 Subject: [PATCH 03/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - add --- .../ci/values-initcontainer.yaml | 35 +++++++++++++++++++ .../charts/medcat-service-helm/ci/values.yaml | 1 + .../templates/extraManifests.yaml | 4 +++ 3 files changed, 40 insertions(+) create mode 100644 deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer.yaml create mode 100644 deployment/kubernetes/charts/medcat-service-helm/ci/values.yaml create mode 100644 deployment/kubernetes/charts/medcat-service-helm/templates/extraManifests.yaml diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer.yaml new file mode 100644 index 0000000..6d71ba2 --- /dev/null +++ b/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer.yaml @@ -0,0 +1,35 @@ +env: + APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" +volumeMounts: + name: model-volume + mountPath: /my/models + +volumes: + - name: model-volume + persistentVolumeClaim: + claimName: medcat-model-pvc + +extraInitContainers: + - name: custom-init-container + image: busybox:1.28 + command: + [ + "sh", + "-c", + "wget -O /my/models/custom-model.zip https://github.com/CogStack/cogstack-nlp/raw/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-service/models/examples/example-medcat-v2-model-pack.zip", + ] + volumeMounts: + - name: model-volume + mountPath: /my/models + +extraManifests: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: medcat-model-pvc + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/values.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/values.yaml new file mode 100644 index 0000000..8626f03 --- /dev/null +++ b/deployment/kubernetes/charts/medcat-service-helm/ci/values.yaml @@ -0,0 +1 @@ +# Empty values file to run CI tests against the defaults diff --git a/deployment/kubernetes/charts/medcat-service-helm/templates/extraManifests.yaml b/deployment/kubernetes/charts/medcat-service-helm/templates/extraManifests.yaml new file mode 100644 index 0000000..928593c --- /dev/null +++ b/deployment/kubernetes/charts/medcat-service-helm/templates/extraManifests.yaml @@ -0,0 +1,4 @@ +{{ range .Values.extraManifests }} +--- +{{ tpl (toYaml .) $ }} +{{ end }} \ No newline at end of file From 92b70f137469ceec08bbcf485f0c65cfaffa270e Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 13:53:29 +0000 Subject: [PATCH 04/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - ci values --- .../ci/{values.yaml => default-values.yaml} | 0 ...ntainer.yaml => initcontainer-values.yaml} | 0 .../docs/platform/deployment/helm/tutorial.md | 23 ++++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) rename deployment/kubernetes/charts/medcat-service-helm/ci/{values.yaml => default-values.yaml} (100%) rename deployment/kubernetes/charts/medcat-service-helm/ci/{values-initcontainer.yaml => initcontainer-values.yaml} (100%) diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/values.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/default-values.yaml similarity index 100% rename from deployment/kubernetes/charts/medcat-service-helm/ci/values.yaml rename to deployment/kubernetes/charts/medcat-service-helm/ci/default-values.yaml diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml similarity index 100% rename from deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer.yaml rename to deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml diff --git a/docs/docs/platform/deployment/helm/tutorial.md b/docs/docs/platform/deployment/helm/tutorial.md index 9851e5f..b47ab4f 100644 --- a/docs/docs/platform/deployment/helm/tutorial.md +++ b/docs/docs/platform/deployment/helm/tutorial.md @@ -9,24 +9,35 @@ We will use the CLI to interact with the cluster, then use Terraform to declarat - Terraform CLI ## Helm Terraform Provider -Terraform is the recommended way to declaritively run CogStack using helm. +Terraform is a recommended way to declaritively run CogStack using helm. ```hcl resource "helm_release" "medcat-service" { - name = "medcat-service-terraform" + name = "medcat-service-helm" chart = "oci://registry-1.docker.io/cogstacksystems/medcat-service-helm" - timeout = 600 - atomic = true } ``` +### Values +We can pass values into the helm chart to customize it. + +```hcl +resource "helm_release" "medcat-service" { + name = "medcat-service-helm" + chart = "oci://registry-1.docker.io/cogstacksystems/medcat-service-helm" + values = [< Date: Thu, 5 Mar 2026 13:55:53 +0000 Subject: [PATCH 05/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - ci values --- .../charts/medcat-service-helm/ci/initcontainer-values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml index 6d71ba2..7f2819a 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml @@ -1,8 +1,8 @@ env: APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" volumeMounts: - name: model-volume - mountPath: /my/models + - name: model-volume + mountPath: /my/models volumes: - name: model-volume From ea561eef3636f5a89edc82f85114495fa5f95ee0 Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 13:56:45 +0000 Subject: [PATCH 06/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - ci values --- .../charts/medcat-service-helm/ci/initcontainer-values.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml index 7f2819a..9559292 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml @@ -1,9 +1,10 @@ +# This values file is used to test the init container functionality +# It shows using an initContainer and a volume to run custom code to download a model pack. env: APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" volumeMounts: - name: model-volume mountPath: /my/models - volumes: - name: model-volume persistentVolumeClaim: From 8a9965daf6b6ef1c63e85cbf442f8317b9ab1fae Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 14:12:30 +0000 Subject: [PATCH 07/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - ci values --- .../ci/initcontainer-values.yaml | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml deleted file mode 100644 index 9559292..0000000 --- a/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# This values file is used to test the init container functionality -# It shows using an initContainer and a volume to run custom code to download a model pack. -env: - APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" -volumeMounts: - - name: model-volume - mountPath: /my/models -volumes: - - name: model-volume - persistentVolumeClaim: - claimName: medcat-model-pvc - -extraInitContainers: - - name: custom-init-container - image: busybox:1.28 - command: - [ - "sh", - "-c", - "wget -O /my/models/custom-model.zip https://github.com/CogStack/cogstack-nlp/raw/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-service/models/examples/example-medcat-v2-model-pack.zip", - ] - volumeMounts: - - name: model-volume - mountPath: /my/models - -extraManifests: - - apiVersion: v1 - kind: PersistentVolumeClaim - metadata: - name: medcat-model-pvc - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi From de5b5cf4efc9a9e49337f6b4681cc201078d815f Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 14:12:37 +0000 Subject: [PATCH 08/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - ci values --- .../ci/values-initcontainer-disabled.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml new file mode 100644 index 0000000..9309a5d --- /dev/null +++ b/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml @@ -0,0 +1,39 @@ +# Note - this is unused, but kept for reference. +# It's unused as the chart testing library only scans for ci/*.values.yaml files +# Currently disabeld as the github URL is not reliable. +# This values file is used to test the init container functionality +# It shows using an initContainer and a volume to run custom code to download a model pack. +env: + APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" +volumeMounts: + - name: model-volume + mountPath: /my/models +volumes: + - name: model-volume + persistentVolumeClaim: + claimName: medcat-model-pvc + +extraInitContainers: + - name: custom-init-container + image: busybox:1.28 + command: + [ + "sh", + "-c", + "wget -O /my/models/custom-model.zip https://github.com/CogStack/cogstack-nlp/raw/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-service/models/examples/example-medcat-v2-model-pack.zip", + ] + volumeMounts: + - name: model-volume + mountPath: /my/models + +extraManifests: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: medcat-model-pvc + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi From 24288ee2b190bd53c10b957d9ecfe38b18ebada7 Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 14:20:04 +0000 Subject: [PATCH 09/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - ci test --- .../ci/values-initcontainer-disabled.yaml | 39 ------------------- .../templates/deployment.yaml | 3 +- 2 files changed, 2 insertions(+), 40 deletions(-) delete mode 100644 deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml deleted file mode 100644 index 9309a5d..0000000 --- a/deployment/kubernetes/charts/medcat-service-helm/ci/values-initcontainer-disabled.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Note - this is unused, but kept for reference. -# It's unused as the chart testing library only scans for ci/*.values.yaml files -# Currently disabeld as the github URL is not reliable. -# This values file is used to test the init container functionality -# It shows using an initContainer and a volume to run custom code to download a model pack. -env: - APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" -volumeMounts: - - name: model-volume - mountPath: /my/models -volumes: - - name: model-volume - persistentVolumeClaim: - claimName: medcat-model-pvc - -extraInitContainers: - - name: custom-init-container - image: busybox:1.28 - command: - [ - "sh", - "-c", - "wget -O /my/models/custom-model.zip https://github.com/CogStack/cogstack-nlp/raw/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-service/models/examples/example-medcat-v2-model-pack.zip", - ] - volumeMounts: - - name: model-volume - mountPath: /my/models - -extraManifests: - - apiVersion: v1 - kind: PersistentVolumeClaim - metadata: - name: medcat-model-pvc - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi diff --git a/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml b/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml index 49983eb..1852686 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml @@ -113,8 +113,9 @@ spec: - name: models mountPath: /models {{- end }} + {{- $root := . -}} {{- with .Values.extraInitContainers }} - {{- tpl (toYaml .) . | nindent 8 }} + {{- tpl (toYaml .) $root | nindent 8 }} {{- end }} {{- if or .Values.model.downloadUrl .Values.volumes }} volumes: From 20cb80e1447e67cbba5c9f4eb13f5f8232b6450c Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Thu, 5 Mar 2026 14:20:41 +0000 Subject: [PATCH 10/10] feat(helm): Medcat service - support custom init container for model loading. Update documentation - ci test --- .../ci/initcontainer-values.yaml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml diff --git a/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml new file mode 100644 index 0000000..431c5e8 --- /dev/null +++ b/deployment/kubernetes/charts/medcat-service-helm/ci/initcontainer-values.yaml @@ -0,0 +1,38 @@ +# This values file is used to test the init container functionality +# It shows using an initContainer and a volume to run custom code to provide a model pack +env: + APP_MEDCAT_MODEL_PACK: "/my/models/custom-model.zip" +volumeMounts: + - name: model-volume + mountPath: /my/models +volumes: + - name: model-volume + persistentVolumeClaim: + claimName: medcat-model-pvc + +extraInitContainers: + - name: custom-init-container + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + # For demo purposes - copy the exmple model pack and reference under new path. + # This demonstrates that we can run any custom code desired to get a model pack. + command: + [ + "sh", + "-c", + "cp /cat/models/examples/example-medcat-v2-model-pack.zip /my/models/custom-model.zip", + ] + volumeMounts: + - name: model-volume + mountPath: /my/models + +extraManifests: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: medcat-model-pvc + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi