From 4118d795254d1fadf64f37fd3e9c0afd45bbeee6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 12 May 2025 19:23:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(helm)=20add=20celery=20deployment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/helm/env.d/dev/values.impress.yaml.gotmpl | 1 + src/helm/impress/Chart.yaml | 2 +- src/helm/impress/README.md | 11 ++ src/helm/impress/templates/_helpers.tpl | 12 ++ .../templates/celery_worker_deployment.yaml | 150 ++++++++++++++++++ src/helm/impress/values.yaml | 28 ++++ 6 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 src/helm/impress/templates/celery_worker_deployment.yaml diff --git a/src/helm/env.d/dev/values.impress.yaml.gotmpl b/src/helm/env.d/dev/values.impress.yaml.gotmpl index 30ada528..c0a3c539 100644 --- a/src/helm/env.d/dev/values.impress.yaml.gotmpl +++ b/src/helm/env.d/dev/values.impress.yaml.gotmpl @@ -56,6 +56,7 @@ backend: POSTGRES_USER: dinum POSTGRES_PASSWORD: pass REDIS_URL: redis://default:pass@redis-master:6379/1 + DJANGO_CELERY_BROKER_URL: redis://default:pass@redis-master:6379/1 AWS_S3_ENDPOINT_URL: http://minio.impress.svc.cluster.local:9000 AWS_S3_ACCESS_KEY_ID: root AWS_S3_SECRET_ACCESS_KEY: password diff --git a/src/helm/impress/Chart.yaml b/src/helm/impress/Chart.yaml index c569e165..8a308f61 100644 --- a/src/helm/impress/Chart.yaml +++ b/src/helm/impress/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 type: application name: docs -version: 3.2.1 +version: 3.3.0-beta.1 appVersion: latest diff --git a/src/helm/impress/README.md b/src/helm/impress/README.md index 18a1f23c..8505b5e4 100644 --- a/src/helm/impress/README.md +++ b/src/helm/impress/README.md @@ -134,6 +134,17 @@ | `backend.pdb.enabled` | Enable pdb on backend | `true` | | `backend.themeCustomization.enabled` | Enable theme customization | `false` | | `backend.themeCustomization.file_content` | Content of the theme customization file. Must be a json object. | `""` | +| `backend.themeCustomization.mount_path` | Path where the customization file will be mounted in the backend deployment. | `/app/configuration/theme/` | +| `backend.celery.replicas` | Amount of celery replicas | `1` | +| `backend.celery.command` | Override the celery container command | `[]` | +| `backend.celery.args` | Override the celery container args | `["celery","-A","impress.celery_app","worker","-l","INFO","-n","impress@%h"]` | +| `backend.celery.resources` | Resource requirements for the celery container | `{}` | +| `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"]` | +| `backend.celery.probes.liveness.initialDelaySeconds` | Initial delay for the celery container liveness probe | `60` | +| `backend.celery.probes.liveness.timeoutSeconds` | Timeout for the celery container liveness probe | `5` | +| `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"]` | +| `backend.celery.probes.readiness.initialDelaySeconds` | Initial delay for the celery container readiness probe | `15` | +| `backend.celery.probes.readiness.timeoutSeconds` | Timeout for the celery container readiness probe | `5` | ### frontend diff --git a/src/helm/impress/templates/_helpers.tpl b/src/helm/impress/templates/_helpers.tpl index b56b9892..921244ed 100644 --- a/src/helm/impress/templates/_helpers.tpl +++ b/src/helm/impress/templates/_helpers.tpl @@ -166,6 +166,18 @@ Requires top level scope {{ include "impress.fullname" . }}-y-provider {{- end }} + +{{/* +Full name for the Celery Worker + +Requires top level scope +*/}} + + +{{- define "impress.celery.worker.fullname" -}} +{{ include "impress.fullname" . }}-celery-worker +{{- end }} + {{/* Usage : {{ include "impress.secret.dockerconfigjson.name" (dict "fullname" (include "impress.fullname" .) "imageCredentials" .Values.path.to.the.image1) }} */}} diff --git a/src/helm/impress/templates/celery_worker_deployment.yaml b/src/helm/impress/templates/celery_worker_deployment.yaml new file mode 100644 index 00000000..956a4e67 --- /dev/null +++ b/src/helm/impress/templates/celery_worker_deployment.yaml @@ -0,0 +1,150 @@ +{{- $envVars := include "impress.common.env" (list . .Values.backend) -}} +{{- $fullName := include "impress.celery.worker.fullname" . -}} +{{- $component := "celery-worker" -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $fullName }} + namespace: {{ .Release.Namespace | quote }} + annotations: + {{- with .Values.backend.dpAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{- include "impress.common.labels" (list . $component) | nindent 4 }} +spec: + replicas: {{ .Values.backend.celery.replicas }} + selector: + matchLabels: + {{- include "impress.common.selectorLabels" (list . $component) | nindent 6 }} + template: + metadata: + annotations: + {{- with .Values.backend.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "impress.common.selectorLabels" (list . $component) | nindent 8 }} + spec: + {{- if $.Values.image.credentials }} + imagePullSecrets: + - name: {{ include "impress.secret.dockerconfigjson.name" (dict "fullname" (include "impress.fullname" .) "imageCredentials" $.Values.image.credentials) }} + {{- end}} + shareProcessNamespace: {{ .Values.backend.shareProcessNamespace }} + containers: + {{- with .Values.backend.sidecars }} + {{- toYaml . | nindent 8 }} + {{- end }} + - name: {{ .Chart.Name }} + image: "{{ (.Values.backend.image | default dict).repository | default .Values.image.repository }}:{{ (.Values.backend.image | default dict).tag | default .Values.image.tag }}" + imagePullPolicy: {{ (.Values.backend.image | default dict).pullPolicy | default .Values.image.pullPolicy }} + {{- with .Values.backend.celery.command }} + command: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.backend.celery.args }} + args: + {{- toYaml . | nindent 12 }} + {{- end }} + env: + {{- if $envVars}} + {{- $envVars | indent 12 }} + {{- end }} + {{- with .Values.backend.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.backend.service.targetPort }} + protocol: TCP + {{- if .Values.backend.celery.probes.liveness }} + livenessProbe: + {{- include "impress.probes.abstract" (merge .Values.backend.celery.probes.liveness (dict "targetPort" .Values.backend.service.targetPort )) | nindent 12 }} + {{- end }} + {{- if .Values.backend.celery.probes.readiness }} + readinessProbe: + {{- include "impress.probes.abstract" (merge .Values.backend.celery.probes.readiness (dict "targetPort" .Values.backend.service.targetPort )) | nindent 12 }} + {{- end }} + {{- if .Values.backend.celery.probes.startup }} + startupProbe: + {{- include "impress.probes.abstract" (merge .Values.backend.celery.probes.startup (dict "targetPort" .Values.backend.service.targetPort )) | nindent 12 }} + {{- end }} + {{- with .Values.backend.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + {{- range $index, $value := .Values.mountFiles }} + - name: "files-{{ $index }}" + mountPath: {{ $value.path }} + subPath: content + {{- end }} + {{- range $name, $volume := .Values.backend.persistence }} + - name: "{{ $name }}" + mountPath: "{{ $volume.mountPath }}" + {{- end }} + {{- range .Values.backend.extraVolumeMounts }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + subPath: {{ .subPath | default "" }} + readOnly: {{ .readOnly }} + {{- end }} + {{- if .Values.backend.themeCustomization.enabled }} + - name: theme-customization + mountPath: {{ .Values.backend.themeCustomization.mount_path }} + readOnly: true + {{- end }} + {{- with .Values.backend.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.backend.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.backend.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + {{- range $index, $value := .Values.mountFiles }} + - name: "files-{{ $index }}" + configMap: + name: "{{ include "impress.fullname" $ }}-files-{{ $index }}" + {{- end }} + {{- range $name, $volume := .Values.backend.persistence }} + - name: "{{ $name }}" + {{- if eq $volume.type "emptyDir" }} + emptyDir: {} + {{- else }} + persistentVolumeClaim: + claimName: "{{ $fullName }}-{{ $name }}" + {{- end }} + {{- end }} + {{- if .Values.backend.themeCustomization.enabled }} + - name: theme-customization + configMap: + name: docs-theme-customization + {{- end }} + {{- range .Values.backend.extraVolumes }} + - name: {{ .name }} + {{- if .existingClaim }} + persistentVolumeClaim: + claimName: {{ .existingClaim }} + {{- else if .hostPath }} + hostPath: + {{ toYaml .hostPath | nindent 12 }} + {{- else if .csi }} + csi: + {{- toYaml .csi | nindent 12 }} + {{- else if .configMap }} + configMap: + {{- toYaml .configMap | nindent 12 }} + {{- else if .emptyDir }} + emptyDir: + {{- toYaml .emptyDir | nindent 12 }} + {{- else }} + emptyDir: {} + {{- end }} + {{- end }} diff --git a/src/helm/impress/values.yaml b/src/helm/impress/values.yaml index 9d6a16d3..989dcbbb 100644 --- a/src/helm/impress/values.yaml +++ b/src/helm/impress/values.yaml @@ -320,6 +320,34 @@ backend: mount_path: /app/configuration/theme/ + ## @param backend.celery.replicas Amount of celery replicas + ## @param backend.celery.command Override the celery container command + ## @param backend.celery.args Override the celery container args + ## @param backend.celery.resources Resource requirements for the celery container + ## @param backend.celery.probes.liveness.exec.command Override the celery container liveness probe command + ## @param backend.celery.probes.liveness.initialDelaySeconds Initial delay for the celery container liveness probe + ## @param backend.celery.probes.liveness.timeoutSeconds Timeout for the celery container liveness probe + ## @param backend.celery.probes.readiness.exec.command Override the celery container readiness probe command + ## @param backend.celery.probes.readiness.initialDelaySeconds Initial delay for the celery container readiness probe + ## @param backend.celery.probes.readiness.timeoutSeconds Timeout for the celery container readiness probe + celery: + replicas: 1 + command: [] + args: ["celery", "-A", "impress.celery_app", "worker", "-l", "INFO", "-n", "impress@%h"] + resources: {} + probes: + liveness: + exec: + command: ["/bin/sh", "-c", "celery -A impress.celery_app inspect ping -d impress@$HOSTNAME"] + initialDelaySeconds: 60 + timeoutSeconds: 5 + readiness: + exec: + command: ["/bin/sh", "-c", "celery -A impress.celery_app inspect ping -d impress@$HOSTNAME"] + initialDelaySeconds: 15 + timeoutSeconds: 5 + + ## @section frontend