Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "medcat-trainer-helm.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "medcat-trainer-helm.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=nginx" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "medcat-trainer-helm.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=medcat-trainer" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[?(@.name==\"nginx\")].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
{{- end }}
backend:
service:
name: {{ include "medcat-trainer-helm.fullname" $ }}-nginx
name: {{ include "medcat-trainer-helm.fullname" $ }}-medcat-trainer
port:
number: {{ $.Values.service.port }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ data:
pidfile=/var/run/supervisord.pid

[program:medcattrainer]
command=sh -c "exec /home/scripts/run.sh 2>&1 | sed 's/^/[medcattrainer] /'"
command=sh -c "exec /home/scripts/run.sh 2>&1 | sed -u 's/^/[medcattrainer] /'"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true

[program:bg-process]
command=sh -c "exec /home/scripts/run-bg-process.sh 2>&1 | sed 's/^/[bg-process] /'"
command=sh -c "exec /home/scripts/run-bg-process.sh 2>&1 | sed -u 's/^/[bg-process] /'"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true

[program:db-backup]
command=sh -c "exec cron -f -l 2 2>&1 | sed 's/^/[db-backup] /'"
command=sh -c "exec cron -f -l 2 2>&1 | sed -u 's/^/[db-backup] /'"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ metadata:
name: {{ include "medcat-trainer-helm.fullname" . }}-medcat-trainer
labels:
{{- include "medcat-trainer-helm.labels" . | nindent 4 }}
app.kubernetes.io/component: medcat-trainer
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "medcat-trainer-helm.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: medcat-trainer
strategy: {{ toYaml .Values.updateStrategy | nindent 4 }}
template:
metadata:
Expand All @@ -22,7 +20,6 @@ spec:
{{- end }}
labels:
{{- include "medcat-trainer-helm.labels" . | nindent 8 }}
app.kubernetes.io/component: medcat-trainer
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -45,8 +42,8 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8000
- name: api
containerPort: {{ .Values.service.apiPort }}
protocol: TCP
args:
- /usr/bin/supervisord
Expand Down Expand Up @@ -93,6 +90,43 @@ spec:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
- name: nginx
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.nginxImage.repository }}:{{ .Values.nginxImage.tag }}"
imagePullPolicy: {{ .Values.nginxImage.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- with .Values.nginx.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nginx.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: nginx-config
mountPath: /etc/nginx/sites-enabled/medcattrainer
subPath: sitesenabled.medcattrainer
- mountPath: /home/api/media
name: api-media
- mountPath: /home/api/static
name: api-static
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: medcat-trainer-config
configMap:
Expand All @@ -111,6 +145,9 @@ spec:
persistentVolumeClaim:
claimName: {{ include "medcat-trainer-helm.fullname" . }}-api-db-backup
{{- end }}
- name: nginx-config
configMap:
name: {{ include "medcat-trainer-helm.fullname" . }}-nginx-config
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ data:
DB_BACKUP_DIR: "/home/api/db-backup"
DB_DIR: "/home/api/db"
DB_PATH: "/home/api/db/db.sqlite3"
MCT_VERSION: {{ .Values.image.tag | default .Chart.AppVersion }}
API_URL: http://localhost:{{ .Values.service.apiPort }}/api/
{{- range $key, $value := .Values.env }}
{{ $key }}: {{ $value | quote }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ include "medcat-trainer-helm.fullname" . }}-secret
labels:
{{- include "medcat-trainer-helm.labels" . | nindent 4 }}
app.kubernetes.io/component: medcat-trainer
stringData:
DB_NAME: {{ .Values.postgresql.auth.database }}
DB_USER: "{{ .Values.postgresql.auth.username }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ data:
}

location / {
proxy_pass http://{{ include "medcat-trainer-helm.fullname" . }}-medcat-trainer:8000;
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@ metadata:
name: {{ include "medcat-trainer-helm.fullname" . }}-medcat-trainer
labels:
{{- include "medcat-trainer-helm.labels" . | nindent 4 }}
app.kubernetes.io/component: medcat-trainer
spec:
type: ClusterIP
ports:
- port: 8000
targetPort: http
protocol: TCP
name: http
selector:
{{- include "medcat-trainer-helm.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: medcat-trainer
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "medcat-trainer-helm.fullname" . }}-nginx
labels:
{{- include "medcat-trainer-helm.labels" . | nindent 4 }}
app.kubernetes.io/component: nginx
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -33,7 +14,10 @@ spec:
targetPort: http
protocol: TCP
name: http
- port: {{ .Values.service.apiPort }}
targetPort: api
protocol: TCP
name: api
selector:
{{- include "medcat-trainer-helm.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: nginx
---
30 changes: 17 additions & 13 deletions deployment/kubernetes/charts/medcat-trainer-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ replicaCount: 1
image:
repository: cogstacksystems/medcat-trainer
# This sets the pull policy for images.
pullPolicy: IfNotPresent
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"
nginxImage:
Expand All @@ -33,6 +33,7 @@ env:
OPENBLAS_NUM_THREADS: "1"
RESUBMIT_ALL_ON_STARTUP: "0"
UNIQUE_DOC_NAMES_IN_DATASETS: "True"
VITE_USE_OIDC: "0"

# TODO: Support custom DB overrides#
# DB_ENGINE: "sqlite3"
Expand Down Expand Up @@ -162,8 +163,10 @@ service:
# This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
type: ClusterIP
# This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports
port: 8000

port: 8001
apiPort: 8000 # Note medcat-trainer API is currently hardcoded on 8000 in the run.sh script
# nodePort: 30001

# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/
ingress:
enabled: false
Expand All @@ -188,27 +191,28 @@ resources: {}
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 3 # Recommended to leave unset. If desired to set note service performance has been found to improve up to around 3 CPU.
# memory: 2Gi
# memory: 4Gi
# requests:
# cpu: 1
# memory: 1Gi
# cpu: 2 # For reference loading the examples on startup measured to use 2CPU and 2Gi memory
# memory: 2Gi

# 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/
livenessProbe:
httpGet:
path: /api/health/live/
port: http
path: /api/health/live/?format=json
port: api
failureThreshold: 30
readinessProbe:
httpGet:
path: /api/health/ready/
port: http
path: /api/health/ready/?format=json
port: api
startupProbe:
httpGet:
path: /api/health/startup/
port: http
path: /api/health/startup/?format=json
port: api
failureThreshold: 30
periodSeconds: 10
initialDelaySeconds: 5
initialDelaySeconds: 15

nginx:
livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion deployment/kubernetes/local_dev_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ helm test medcat-service --logs
# Test medcat trainer
# kubectl port-forward svc/nginx 8000:8000

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

## helm install trainer-registry oci://registry-1.docker.io/cogstacksystems/medcat-trainer-helm --wait --timeout 5m0s
Loading