Skip to content

Commit bbbf5d2

Browse files
fix(helm): Medcat trainer helm chart to support preset auth for postgres (#36)
* fix(helm): Set postgres user/pass in value to fix restart issue * fix(helm): Set Trainer ingress service to nginx * feat(helm): Make medcat-service ingress support the standard template pattern
1 parent a54f66c commit bbbf5d2

7 files changed

Lines changed: 63 additions & 33 deletions

File tree

deployment/kubernetes/charts/medcat-service-helm/templates/ingress.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ spec:
2424
{{- end }}
2525
{{- end }}
2626
rules:
27+
{{- if not .Values.ingress.http }}
28+
{{- range .Values.ingress.hosts }}
29+
- host: {{ .host | quote }}
30+
http:
31+
paths:
32+
{{- range .paths }}
33+
- path: {{ .path }}
34+
{{- with .pathType }}
35+
pathType: {{ . }}
36+
{{- end }}
37+
backend:
38+
service:
39+
name: {{ include "medcat-service.fullname" $ }}
40+
port:
41+
number: {{ $.Values.service.port }}
42+
{{- end }}
43+
{{- end }}
44+
{{- end }}
45+
{{- if not .Values.ingress.hosts }}
2746
{{- range .Values.ingress.http }}
2847
- {{- if .host }}
2948
host: {{ .host | quote }}
@@ -42,4 +61,5 @@ spec:
4261
number: {{ $.Values.service.port }}
4362
{{- end }}
4463
{{- end }}
64+
{{- end }}
4565
{{- end }}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,16 @@ ingress:
144144
annotations: {}
145145
# kubernetes.io/ingress.class: nginx
146146
# kubernetes.io/tls-acme: "true"
147-
http:
147+
hosts:
148148
- host: chart-example.local
149149
paths:
150150
- path: /
151151
pathType: ImplementationSpecific
152-
# Allows global ingress without hostname, matching all calls to the host.
153-
- paths:
154-
- path: /medcat-service
155-
pathType: ImplementationSpecific
152+
# - Optional alternative to hosts: allows for global ingress without hostname. Overrides hosts if both are set.
153+
# http:
154+
# - paths:
155+
# - path: /medcat-service
156+
# pathType: ImplementationSpecific
156157
tls: []
157158
# - secretName: chart-example-tls
158159
# hosts:

deployment/kubernetes/charts/medcat-trainer-helm/templates/_helpers.tpl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ Create the name of the service account to use
6262
{{- end }}
6363
{{- end }}
6464

65+
{{/* =========================================================================
66+
Dependencies
67+
=========================================================================== */}}
6568

6669
{{- /*
6770
Return Solr host: either user-supplied or constructed from release name
@@ -92,4 +95,12 @@ Return full Solr URL: combines host and port
9295
*/ -}}
9396
{{- define "medcat-trainer-helm.solrURL" -}}
9497
http://{{ include "medcat-trainer-helm.solrHost" . }}:{{ include "medcat-trainer-helm.solrPort" . }}
95-
{{- end }}
98+
{{- end }}
99+
100+
{{- define "postgres.service-name" -}}
101+
{{ include "postgresql.v1.primary.fullname" (dict "Values" .Values.postgresql "Chart" (dict "Name" "postgresql") "Release" .Release) }}
102+
{{- end -}}
103+
104+
{{- define "postgres.port" -}}
105+
{{ include "postgresql.v1.service.port" (dict "Values" .Values.postgresql) }}
106+
{{- end -}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
{{- end }}
3636
backend:
3737
service:
38-
name: {{ include "medcat-trainer-helm.fullname" $ }}
38+
name: {{ include "medcat-trainer-helm.fullname" $ }}-nginx
3939
port:
4040
number: {{ $.Values.service.port }}
4141
{{- end }}

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,8 @@ spec:
5555
envFrom:
5656
- configMapRef:
5757
name: {{ include "medcat-trainer-helm.fullname" . }}-medcat-trainer-env
58-
{{- if .Values.postgresql.enabled }}
59-
env:
60-
- name: DB_HOST
61-
value: {{ .Release.Name }}-postgresql
62-
- name: DB_PASSWORD
63-
valueFrom:
64-
secretKeyRef:
65-
name: {{ .Release.Name }}-postgresql
66-
key: postgres-password
67-
{{- end }}
58+
- secretRef:
59+
name: {{ include "medcat-trainer-helm.fullname" . }}-secret
6860
{{- with .Values.livenessProbe }}
6961
livenessProbe:
7062
{{- toYaml . | nindent 12 }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "medcat-trainer-helm.fullname" . }}-secret
5+
labels:
6+
{{- include "medcat-trainer-helm.labels" . | nindent 4 }}
7+
stringData:
8+
DB_NAME: {{ .Values.postgresql.auth.database }}
9+
DB_USER: "{{ .Values.postgresql.auth.username }}"
10+
DB_PASSWORD: "{{ .Values.postgresql.auth.password }}"
11+
DB_HOST: "{{ include "postgresql.v1.primary.fullname" (dict "Values" .Values.postgresql "Chart" (dict "Name" "postgresql") "Release" .Release) }}"
12+
DB_PORT: "{{ include "postgresql.v1.service.port" (dict "Values" .Values.postgresql) }}"
13+

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
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: 1
87

98
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
109
image:
1110
repository: cogstacksystems/medcat-trainer
1211
# This sets the pull policy for images.
13-
pullPolicy: Always
12+
pullPolicy: IfNotPresent
1413
# Overrides the image tag whose default is the chart appVersion.
1514
tag: "latest"
1615
nginxImage:
@@ -38,20 +37,15 @@ env:
3837
# TODO: Support custom DB overrides#
3938
# DB_ENGINE: "sqlite3"
4039
DB_ENGINE: "postgresql"
41-
DB_NAME: "postgres"
42-
DB_USER: "postgres"
4340
DB_PORT: "5432"
44-
# DB_PASSWORD: ""
45-
# DB_HOST: ""
4641

4742
postgresql:
4843
enabled: true
4944
# 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"
45+
auth:
46+
database: "postgres"
47+
username: "postgres"
48+
password: "postgres"
5549
primary:
5650
persistence:
5751
# Size of the PVC for the postgres database
@@ -96,10 +90,7 @@ solr:
9690
replicaCount: 1
9791
collectionShards: 1
9892
collectionReplicas: 1
99-
zookeeper:
100-
replicaCount: 1
101-
persistence:
102-
size: 1Gi
93+
10394
persistence:
10495
size: 1Gi
10596
auth:
@@ -117,7 +108,9 @@ solr:
117108
image:
118109
repository: bitnamilegacy/zookeeper
119110
tag: 3.9.3-debian-12-r22
120-
111+
replicaCount: 1 #
112+
persistence:
113+
size: 1Gi # Default is 8Gi
121114

122115

123116
# 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/

0 commit comments

Comments
 (0)