Skip to content

Commit 6e64be1

Browse files
committed
build(k8s): enable maintenance mode on k8s
1 parent 527ef69 commit 6e64be1

File tree

5 files changed

+93
-1
lines changed

5 files changed

+93
-1
lines changed

k8s/templates/backend.deployment.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ spec:
6363
image: {{ include "chart.lifemonitor.image" . }}
6464
imagePullPolicy: {{ .Values.lifemonitor.imagePullPolicy }}
6565
env:
66-
{{- include "lifemonitor.common-env" . | nindent 12 }}
66+
{{- include "lifemonitor.common-env" . | nindent 12 }}
67+
{{- if .Values.maintenanceMode.enabled }}
68+
- name: FLASK_ENV
69+
value: "maintenance"
70+
{{- end }}
6771
volumeMounts:
6872
{{- include "lifemonitor.common-volume-mounts" . | nindent 12 }}
6973
ports:

k8s/templates/console.deployment.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{{- if or (.Values.maintenanceMode.enabled) (.Values.console.enabled ) }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "chart.fullname" . }}-console
6+
labels:
7+
{{- include "chart.labels" . | nindent 4 }}
8+
spec:
9+
{{- if not .Values.lifemonitor.autoscaling.enabled }}
10+
replicas: {{ .Values.lifemonitor.replicaCount }}
11+
{{- end }}
12+
selector:
13+
matchLabels:
14+
{{- include "chart.selectorLabels" . | nindent 6 }}
15+
template:
16+
metadata:
17+
annotations:
18+
checksum/settings: {{ include (print $.Template.BasePath "/settings.secret.yaml") . | sha256sum }}
19+
{{- with .Values.lifemonitor.podAnnotations }}
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
labels:
23+
{{- include "chart.selectorLabels" . | nindent 8 }}
24+
spec:
25+
{{- with .Values.lifemonitor.imagePullSecrets }}
26+
imagePullSecrets:
27+
{{- toYaml . | nindent 8 }}
28+
{{- end }}
29+
serviceAccountName: {{ include "chart.serviceAccountName" . }}
30+
securityContext:
31+
{{- toYaml .Values.lifemonitor.podSecurityContext | nindent 8 }}
32+
containers:
33+
- name: app
34+
securityContext:
35+
{{- toYaml .Values.lifemonitor.securityContext | nindent 12 }}
36+
image: {{ include "chart.lifemonitor.image" . }}
37+
imagePullPolicy: {{ .Values.lifemonitor.imagePullPolicy }}
38+
command: ["/bin/sh","-c"]
39+
args: ["wait-for-redis.sh && wait-for-postgres.sh && sleep infinity"]
40+
env:
41+
{{- include "lifemonitor.common-env" . | nindent 12 }}
42+
- name: LIFEMONITOR_MAINTENANCE_MODE
43+
value: {{ .Values.maintenanceMode.enabled | quote }}
44+
- name: LIFEMONITOR_CONSOLE_ENABLED
45+
value: {{ .Values.console.enabled | quote }}
46+
volumeMounts:
47+
{{- include "lifemonitor.common-volume-mounts" . | nindent 12 }}
48+
- name: lifemonitor-backup
49+
mountPath: "/var/data/backup"
50+
ports:
51+
- name: http
52+
containerPort: 8000
53+
protocol: TCP
54+
resources:
55+
{{- toYaml .Values.lifemonitor.resources | nindent 12 }}
56+
volumes:
57+
- name: lifemonitor-backup
58+
persistentVolumeClaim:
59+
claimName: {{ .Values.backup.existingClaim }}
60+
{{- include "lifemonitor.common-volume" . | nindent 8 }}
61+
{{- with .Values.lifemonitor.nodeSelector }}
62+
nodeSelector:
63+
{{- toYaml . | nindent 8 }}
64+
{{- end }}
65+
{{- with .Values.lifemonitor.affinity }}
66+
affinity:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
{{- with .Values.lifemonitor.tolerations }}
70+
tolerations:
71+
{{- toYaml . | nindent 8 }}
72+
{{- end }}
73+
{{- end }}

k8s/templates/worker.deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ spec:
7272
{{ else }}
7373
value: {{ $queue.name }}
7474
{{ end }}
75+
{{- if $.Values.maintenanceMode.enabled }}
76+
- name: FLASK_ENV
77+
value: "maintenance"
78+
{{- end }}
7579
ports:
7680
- containerPort: 9191
7781
volumeMounts:

k8s/templates/wss.deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ spec:
6060
imagePullPolicy: {{ .Values.lifemonitor.imagePullPolicy }}
6161
env:
6262
{{- include "lifemonitor.common-env" . | nindent 12 }}
63+
{{- if .Values.maintenanceMode.enabled }}
64+
- name: FLASK_ENV
65+
value: "maintenance"
66+
{{- end }}
6367
volumeMounts:
6468
{{- include "lifemonitor.common-volume-mounts" . | nindent 12 }}
6569
ports:

k8s/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
nameOverride: ""
77
fullnameOverride: ""
88

9+
# manage maintenance mode
10+
maintenanceMode:
11+
enabled: false
912
# The name and port number of the server (e.g.: 'lm.local:8000'),
1013
# used as base_url on all the links returned by the API
1114
externalServerName: &hostname api.lifemonitor.eu
@@ -151,6 +154,10 @@ monitoring:
151154
memory: 256Mi
152155
cpu: 0.2
153156

157+
# management console settings
158+
console:
159+
enabled: false
160+
154161
rateLimiting:
155162
zone:
156163
accounts:

0 commit comments

Comments
 (0)