From 5f6c030a98ce92c21866d778a6809101604034a2 Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Mon, 20 Oct 2025 14:41:50 +0000 Subject: [PATCH 1/3] ops: Support setting NodePort in helm charts --- .../charts/medcat-service-helm/templates/service.yaml | 3 +++ .../charts/medcat-trainer-helm/templates/service.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml b/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml index 9eee849..2e11b22 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml @@ -11,5 +11,8 @@ spec: targetPort: http protocol: TCP name: http + {{- if (and (eq .Values.service.type "NodePort") ( .Values.service.nodePort)) }} + nodePort: {{ .Values.service.nodePort }} + {{- else }} selector: {{- include "medcat-service.selectorLabels" . | nindent 4 }} diff --git a/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml b/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml index 8151698..cd1c7a2 100644 --- a/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml +++ b/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml @@ -27,6 +27,9 @@ spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} + {{- if (and (eq .Values.service.type "NodePort") ( .Values.service.nodePort)) }} + nodePort: {{ .Values.service.nodePort }} + {{- else }} targetPort: http protocol: TCP name: http From 4ed18a1d534aee014565196f1860cd8aae59060a Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Tue, 21 Oct 2025 10:05:26 +0000 Subject: [PATCH 2/3] ops: Support setting NodePort in helm charts --- .../charts/medcat-service-helm/templates/service.yaml | 2 +- .../charts/medcat-trainer-helm/templates/service.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml b/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml index 2e11b22..0523aca 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/templates/service.yaml @@ -13,6 +13,6 @@ spec: name: http {{- if (and (eq .Values.service.type "NodePort") ( .Values.service.nodePort)) }} nodePort: {{ .Values.service.nodePort }} - {{- else }} + {{- end }} selector: {{- include "medcat-service.selectorLabels" . | nindent 4 }} diff --git a/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml b/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml index cd1c7a2..799a0db 100644 --- a/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml +++ b/deployment/kubernetes/charts/medcat-trainer-helm/templates/service.yaml @@ -29,7 +29,7 @@ spec: - port: {{ .Values.service.port }} {{- if (and (eq .Values.service.type "NodePort") ( .Values.service.nodePort)) }} nodePort: {{ .Values.service.nodePort }} - {{- else }} + {{- end }} targetPort: http protocol: TCP name: http From 21c2eafe6fc5e8929417d5dca20d6f01699dda72 Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Tue, 21 Oct 2025 14:54:37 +0000 Subject: [PATCH 3/3] ops: In helm support initContainer for model download on startup --- .../templates/deployment.yaml | 47 +++++++++++++++++-- .../charts/medcat-service-helm/values.yaml | 7 +++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml b/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml index f4f32e5..595467f 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/templates/deployment.yaml @@ -54,6 +54,11 @@ spec: - name: "{{ tpl $key $ }}" value: "{{ tpl (print $value) $ }}" {{- end }} + {{- if .Values.model.downloadUrl }} + # Note this overrides any previous env setting if downloading is enabled + - name: "APP_MEDCAT_MODEL_PACK" + value: "/models/{{ .Values.model.name}}" + {{- end}} {{- with .Values.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} @@ -70,13 +75,47 @@ spec: resources: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.volumeMounts }} + {{- if or .Values.model.downloadUrl .Values.volumeMounts }} volumeMounts: - {{- toYaml . | nindent 12 }} + {{- if .Values.volumeMounts }} + {{- toYaml .Values.volumeMounts | nindent 2 }} + {{- end }} + {{- if .Values.model.downloadUrl }} + - name: models + mountPath: /models + {{- end }} {{- end }} - {{- with .Values.volumes }} + {{- if .Values.model.downloadUrl }} + initContainers: + - name: model-downloader + image: busybox:1.28 + command: + - sh + - -c + - | + echo "Downloading model $MODEL_NAME from $MODEL_PACK_URL" + mkdir -p /models + wget -O "/models/$MODEL_NAME" "$MODEL_PACK_URL" + echo "Download finished" + env: + - name: MODEL_PACK_URL + value: {{ .Values.model.downloadUrl}} + - name: MODEL_NAME + value: {{ .Values.model.name}} + volumeMounts: + - name: models + mountPath: /models + {{- end }} + + {{- if or .Values.model.downloadUrl .Values.volumes }} volumes: - {{- toYaml . | nindent 8 }} + {{- if .Values.volumes }} + {{- toYaml .Values.volumes | nindent 2 }} + {{- end }} + {{- if .Values.model.downloadUrl }} + - name: models + emptyDir: {} + {{- end }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: diff --git a/deployment/kubernetes/charts/medcat-service-helm/values.yaml b/deployment/kubernetes/charts/medcat-service-helm/values.yaml index 59a7452..9f6cc8e 100644 --- a/deployment/kubernetes/charts/medcat-service-helm/values.yaml +++ b/deployment/kubernetes/charts/medcat-service-helm/values.yaml @@ -31,6 +31,13 @@ env: # DEID_MODE: true # DEID_REDACT: true +# Enable downloading of public models using wget on startup. Model will be downloaded to /models/ and used for APP_MEDCAT_MODEL_PACK +# model: + # Public URL to download a model pack from + # downloadUrl: "http://localhost:9000/models/my-model.zip" + # Name of the model pack to save to. Will be stored at /models/ + # name: my-model.zip + # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: [] # This is to override the chart name.