Skip to content

Commit 4118d79

Browse files
committed
🔧(helm) add celery deployment
We need to configure a deployment dedicated to celery. It is a copy of the backend one with modification made where it is specific to celery
1 parent 5848f43 commit 4118d79

File tree

6 files changed

+203
-1
lines changed

6 files changed

+203
-1
lines changed

src/helm/env.d/dev/values.impress.yaml.gotmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ backend:
5656
POSTGRES_USER: dinum
5757
POSTGRES_PASSWORD: pass
5858
REDIS_URL: redis://default:pass@redis-master:6379/1
59+
DJANGO_CELERY_BROKER_URL: redis://default:pass@redis-master:6379/1
5960
AWS_S3_ENDPOINT_URL: http://minio.impress.svc.cluster.local:9000
6061
AWS_S3_ACCESS_KEY_ID: root
6162
AWS_S3_SECRET_ACCESS_KEY: password

src/helm/impress/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
22
type: application
33
name: docs
4-
version: 3.2.1
4+
version: 3.3.0-beta.1
55
appVersion: latest

src/helm/impress/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@
134134
| `backend.pdb.enabled` | Enable pdb on backend | `true` |
135135
| `backend.themeCustomization.enabled` | Enable theme customization | `false` |
136136
| `backend.themeCustomization.file_content` | Content of the theme customization file. Must be a json object. | `""` |
137+
| `backend.themeCustomization.mount_path` | Path where the customization file will be mounted in the backend deployment. | `/app/configuration/theme/` |
138+
| `backend.celery.replicas` | Amount of celery replicas | `1` |
139+
| `backend.celery.command` | Override the celery container command | `[]` |
140+
| `backend.celery.args` | Override the celery container args | `["celery","-A","impress.celery_app","worker","-l","INFO","-n","impress@%h"]` |
141+
| `backend.celery.resources` | Resource requirements for the celery container | `{}` |
142+
| `backend.celery.probes.liveness.exec.command` | Override the celery container liveness probe command | `["/bin/sh","-c","celery -A impress.celery_app inspect ping -d impress@$HOSTNAME"]` |
143+
| `backend.celery.probes.liveness.initialDelaySeconds` | Initial delay for the celery container liveness probe | `60` |
144+
| `backend.celery.probes.liveness.timeoutSeconds` | Timeout for the celery container liveness probe | `5` |
145+
| `backend.celery.probes.readiness.exec.command` | Override the celery container readiness probe command | `["/bin/sh","-c","celery -A impress.celery_app inspect ping -d impress@$HOSTNAME"]` |
146+
| `backend.celery.probes.readiness.initialDelaySeconds` | Initial delay for the celery container readiness probe | `15` |
147+
| `backend.celery.probes.readiness.timeoutSeconds` | Timeout for the celery container readiness probe | `5` |
137148

138149
### frontend
139150

src/helm/impress/templates/_helpers.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ Requires top level scope
166166
{{ include "impress.fullname" . }}-y-provider
167167
{{- end }}
168168

169+
170+
{{/*
171+
Full name for the Celery Worker
172+
173+
Requires top level scope
174+
*/}}
175+
176+
177+
{{- define "impress.celery.worker.fullname" -}}
178+
{{ include "impress.fullname" . }}-celery-worker
179+
{{- end }}
180+
169181
{{/*
170182
Usage : {{ include "impress.secret.dockerconfigjson.name" (dict "fullname" (include "impress.fullname" .) "imageCredentials" .Values.path.to.the.image1) }}
171183
*/}}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{{- $envVars := include "impress.common.env" (list . .Values.backend) -}}
2+
{{- $fullName := include "impress.celery.worker.fullname" . -}}
3+
{{- $component := "celery-worker" -}}
4+
apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
name: {{ $fullName }}
8+
namespace: {{ .Release.Namespace | quote }}
9+
annotations:
10+
{{- with .Values.backend.dpAnnotations }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
labels:
14+
{{- include "impress.common.labels" (list . $component) | nindent 4 }}
15+
spec:
16+
replicas: {{ .Values.backend.celery.replicas }}
17+
selector:
18+
matchLabels:
19+
{{- include "impress.common.selectorLabels" (list . $component) | nindent 6 }}
20+
template:
21+
metadata:
22+
annotations:
23+
{{- with .Values.backend.podAnnotations }}
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
labels:
27+
{{- include "impress.common.selectorLabels" (list . $component) | nindent 8 }}
28+
spec:
29+
{{- if $.Values.image.credentials }}
30+
imagePullSecrets:
31+
- name: {{ include "impress.secret.dockerconfigjson.name" (dict "fullname" (include "impress.fullname" .) "imageCredentials" $.Values.image.credentials) }}
32+
{{- end}}
33+
shareProcessNamespace: {{ .Values.backend.shareProcessNamespace }}
34+
containers:
35+
{{- with .Values.backend.sidecars }}
36+
{{- toYaml . | nindent 8 }}
37+
{{- end }}
38+
- name: {{ .Chart.Name }}
39+
image: "{{ (.Values.backend.image | default dict).repository | default .Values.image.repository }}:{{ (.Values.backend.image | default dict).tag | default .Values.image.tag }}"
40+
imagePullPolicy: {{ (.Values.backend.image | default dict).pullPolicy | default .Values.image.pullPolicy }}
41+
{{- with .Values.backend.celery.command }}
42+
command:
43+
{{- toYaml . | nindent 12 }}
44+
{{- end }}
45+
{{- with .Values.backend.celery.args }}
46+
args:
47+
{{- toYaml . | nindent 12 }}
48+
{{- end }}
49+
env:
50+
{{- if $envVars}}
51+
{{- $envVars | indent 12 }}
52+
{{- end }}
53+
{{- with .Values.backend.securityContext }}
54+
securityContext:
55+
{{- toYaml . | nindent 12 }}
56+
{{- end }}
57+
ports:
58+
- name: http
59+
containerPort: {{ .Values.backend.service.targetPort }}
60+
protocol: TCP
61+
{{- if .Values.backend.celery.probes.liveness }}
62+
livenessProbe:
63+
{{- include "impress.probes.abstract" (merge .Values.backend.celery.probes.liveness (dict "targetPort" .Values.backend.service.targetPort )) | nindent 12 }}
64+
{{- end }}
65+
{{- if .Values.backend.celery.probes.readiness }}
66+
readinessProbe:
67+
{{- include "impress.probes.abstract" (merge .Values.backend.celery.probes.readiness (dict "targetPort" .Values.backend.service.targetPort )) | nindent 12 }}
68+
{{- end }}
69+
{{- if .Values.backend.celery.probes.startup }}
70+
startupProbe:
71+
{{- include "impress.probes.abstract" (merge .Values.backend.celery.probes.startup (dict "targetPort" .Values.backend.service.targetPort )) | nindent 12 }}
72+
{{- end }}
73+
{{- with .Values.backend.resources }}
74+
resources:
75+
{{- toYaml . | nindent 12 }}
76+
{{- end }}
77+
volumeMounts:
78+
{{- range $index, $value := .Values.mountFiles }}
79+
- name: "files-{{ $index }}"
80+
mountPath: {{ $value.path }}
81+
subPath: content
82+
{{- end }}
83+
{{- range $name, $volume := .Values.backend.persistence }}
84+
- name: "{{ $name }}"
85+
mountPath: "{{ $volume.mountPath }}"
86+
{{- end }}
87+
{{- range .Values.backend.extraVolumeMounts }}
88+
- name: {{ .name }}
89+
mountPath: {{ .mountPath }}
90+
subPath: {{ .subPath | default "" }}
91+
readOnly: {{ .readOnly }}
92+
{{- end }}
93+
{{- if .Values.backend.themeCustomization.enabled }}
94+
- name: theme-customization
95+
mountPath: {{ .Values.backend.themeCustomization.mount_path }}
96+
readOnly: true
97+
{{- end }}
98+
{{- with .Values.backend.nodeSelector }}
99+
nodeSelector:
100+
{{- toYaml . | nindent 8 }}
101+
{{- end }}
102+
{{- with .Values.backend.affinity }}
103+
affinity:
104+
{{- toYaml . | nindent 8 }}
105+
{{- end }}
106+
{{- with .Values.backend.tolerations }}
107+
tolerations:
108+
{{- toYaml . | nindent 8 }}
109+
{{- end }}
110+
volumes:
111+
{{- range $index, $value := .Values.mountFiles }}
112+
- name: "files-{{ $index }}"
113+
configMap:
114+
name: "{{ include "impress.fullname" $ }}-files-{{ $index }}"
115+
{{- end }}
116+
{{- range $name, $volume := .Values.backend.persistence }}
117+
- name: "{{ $name }}"
118+
{{- if eq $volume.type "emptyDir" }}
119+
emptyDir: {}
120+
{{- else }}
121+
persistentVolumeClaim:
122+
claimName: "{{ $fullName }}-{{ $name }}"
123+
{{- end }}
124+
{{- end }}
125+
{{- if .Values.backend.themeCustomization.enabled }}
126+
- name: theme-customization
127+
configMap:
128+
name: docs-theme-customization
129+
{{- end }}
130+
{{- range .Values.backend.extraVolumes }}
131+
- name: {{ .name }}
132+
{{- if .existingClaim }}
133+
persistentVolumeClaim:
134+
claimName: {{ .existingClaim }}
135+
{{- else if .hostPath }}
136+
hostPath:
137+
{{ toYaml .hostPath | nindent 12 }}
138+
{{- else if .csi }}
139+
csi:
140+
{{- toYaml .csi | nindent 12 }}
141+
{{- else if .configMap }}
142+
configMap:
143+
{{- toYaml .configMap | nindent 12 }}
144+
{{- else if .emptyDir }}
145+
emptyDir:
146+
{{- toYaml .emptyDir | nindent 12 }}
147+
{{- else }}
148+
emptyDir: {}
149+
{{- end }}
150+
{{- end }}

src/helm/impress/values.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,34 @@ backend:
320320
mount_path: /app/configuration/theme/
321321

322322

323+
## @param backend.celery.replicas Amount of celery replicas
324+
## @param backend.celery.command Override the celery container command
325+
## @param backend.celery.args Override the celery container args
326+
## @param backend.celery.resources Resource requirements for the celery container
327+
## @param backend.celery.probes.liveness.exec.command Override the celery container liveness probe command
328+
## @param backend.celery.probes.liveness.initialDelaySeconds Initial delay for the celery container liveness probe
329+
## @param backend.celery.probes.liveness.timeoutSeconds Timeout for the celery container liveness probe
330+
## @param backend.celery.probes.readiness.exec.command Override the celery container readiness probe command
331+
## @param backend.celery.probes.readiness.initialDelaySeconds Initial delay for the celery container readiness probe
332+
## @param backend.celery.probes.readiness.timeoutSeconds Timeout for the celery container readiness probe
333+
celery:
334+
replicas: 1
335+
command: []
336+
args: ["celery", "-A", "impress.celery_app", "worker", "-l", "INFO", "-n", "impress@%h"]
337+
resources: {}
338+
probes:
339+
liveness:
340+
exec:
341+
command: ["/bin/sh", "-c", "celery -A impress.celery_app inspect ping -d impress@$HOSTNAME"]
342+
initialDelaySeconds: 60
343+
timeoutSeconds: 5
344+
readiness:
345+
exec:
346+
command: ["/bin/sh", "-c", "celery -A impress.celery_app inspect ping -d impress@$HOSTNAME"]
347+
initialDelaySeconds: 15
348+
timeoutSeconds: 5
349+
350+
323351

324352
## @section frontend
325353

0 commit comments

Comments
 (0)