From a83902a0d43f5dc76f182422e500c04fd43675bd Mon Sep 17 00:00:00 2001 From: Jacques ROUSSEL Date: Thu, 5 Jun 2025 16:40:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8(helm)=20improve=20helm=20chart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our Helm chart wasn't suitable for use with Helm alone because jobs remained after deployment. We chose to configure ttlSecondsAfterFinished to clean up jobs after a period of time. --- src/helm/env.d/dev/values.impress.yaml.gotmpl | 15 ++ src/helm/impress/Chart.yaml | 2 +- src/helm/impress/README.md | 134 +++++++++--------- .../backend_job_createsuperuser.yaml | 2 + .../templates/backend_job_migrate.yaml | 2 + src/helm/impress/values.yaml | 30 +++- 6 files changed, 114 insertions(+), 71 deletions(-) diff --git a/src/helm/env.d/dev/values.impress.yaml.gotmpl b/src/helm/env.d/dev/values.impress.yaml.gotmpl index 57e92cd5..d7d89211 100644 --- a/src/helm/env.d/dev/values.impress.yaml.gotmpl +++ b/src/helm/env.d/dev/values.impress.yaml.gotmpl @@ -68,6 +68,14 @@ backend: - "/bin/sh" - "-c" - | + while ! python manage.py check --database default > /dev/null 2>&1 + do + echo "Database not ready" + sleep 2 + done + + echo "Database is ready" + python manage.py migrate --no-input && python manage.py create_demo --force restartPolicy: Never @@ -84,6 +92,13 @@ backend: - "/bin/sh" - "-c" - | + while ! python manage.py check --database default > /dev/null 2>&1 + do + echo "Database not ready" + sleep 2 + done + + echo "Database is ready" python manage.py createsuperuser --email admin@example.com --password admin restartPolicy: Never diff --git a/src/helm/impress/Chart.yaml b/src/helm/impress/Chart.yaml index f370dd35..96a61746 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.3.0 +version: 3.4.0-beta.1 appVersion: latest diff --git a/src/helm/impress/README.md b/src/helm/impress/README.md index 8505b5e4..501b4cc3 100644 --- a/src/helm/impress/README.md +++ b/src/helm/impress/README.md @@ -79,72 +79,74 @@ ### backend -| Name | Description | Value | -| ----------------------------------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -| `backend.command` | Override the backend container command | `[]` | -| `backend.args` | Override the backend container args | `[]` | -| `backend.replicas` | Amount of backend replicas | `3` | -| `backend.shareProcessNamespace` | Enable share process namespace between containers | `false` | -| `backend.sidecars` | Add sidecars containers to backend deployment | `[]` | -| `backend.migrateJobAnnotations` | Annotations for the migrate job | `{}` | -| `backend.securityContext` | Configure backend Pod security context | `nil` | -| `backend.envVars` | Configure backend container environment variables | `undefined` | -| `backend.envVars.BY_VALUE` | Example environment variable by setting value directly | | -| `backend.envVars.FROM_CONFIGMAP.configMapKeyRef.name` | Name of a ConfigMap when configuring env vars from a ConfigMap | | -| `backend.envVars.FROM_CONFIGMAP.configMapKeyRef.key` | Key within a ConfigMap when configuring env vars from a ConfigMap | | -| `backend.envVars.FROM_SECRET.secretKeyRef.name` | Name of a Secret when configuring env vars from a Secret | | -| `backend.envVars.FROM_SECRET.secretKeyRef.key` | Key within a Secret when configuring env vars from a Secret | | -| `backend.podAnnotations` | Annotations to add to the backend Pod | `{}` | -| `backend.dpAnnotations` | Annotations to add to the backend Deployment | `{}` | -| `backend.service.type` | backend Service type | `ClusterIP` | -| `backend.service.port` | backend Service listening port | `80` | -| `backend.service.targetPort` | backend container listening port | `8000` | -| `backend.service.annotations` | Annotations to add to the backend Service | `{}` | -| `backend.migrate.command` | backend migrate command | `["python","manage.py","migrate","--no-input"]` | -| `backend.migrate.restartPolicy` | backend migrate job restart policy | `Never` | -| `backend.createsuperuser.command` | backend migrate command | `["/bin/sh","-c","python manage.py createsuperuser --email $DJANGO_SUPERUSER_EMAIL --password $DJANGO_SUPERUSER_PASSWORD\n"]` | -| `backend.createsuperuser.restartPolicy` | backend migrate job restart policy | `Never` | -| `backend.job` | job dedicated to run a random management command, for example after a deployment | | -| `backend.job.name` | The name to use to describe this job | `""` | -| `backend.job.command` | The management command to execute | `[]` | -| `backend.job.restartPolicy` | The restart policy for the job. | `Never` | -| `backend.job.annotations` | Annotations to add to the job [default: argocd.argoproj.io/hook: PostSync] | | -| `backend.probes.liveness.path` | Configure path for backend HTTP liveness probe | `/__heartbeat__` | -| `backend.probes.liveness.targetPort` | Configure port for backend HTTP liveness probe | `undefined` | -| `backend.probes.liveness.initialDelaySeconds` | Configure initial delay for backend liveness probe | `10` | -| `backend.probes.liveness.initialDelaySeconds` | Configure timeout for backend liveness probe | `10` | -| `backend.probes.startup.path` | Configure path for backend HTTP startup probe | `undefined` | -| `backend.probes.startup.targetPort` | Configure port for backend HTTP startup probe | `undefined` | -| `backend.probes.startup.initialDelaySeconds` | Configure initial delay for backend startup probe | `undefined` | -| `backend.probes.startup.initialDelaySeconds` | Configure timeout for backend startup probe | `undefined` | -| `backend.probes.readiness.path` | Configure path for backend HTTP readiness probe | `/__lbheartbeat__` | -| `backend.probes.readiness.targetPort` | Configure port for backend HTTP readiness probe | `undefined` | -| `backend.probes.readiness.initialDelaySeconds` | Configure initial delay for backend readiness probe | `10` | -| `backend.probes.readiness.initialDelaySeconds` | Configure timeout for backend readiness probe | `10` | -| `backend.resources` | Resource requirements for the backend container | `{}` | -| `backend.nodeSelector` | Node selector for the backend Pod | `{}` | -| `backend.tolerations` | Tolerations for the backend Pod | `[]` | -| `backend.affinity` | Affinity for the backend Pod | `{}` | -| `backend.persistence` | Additional volumes to create and mount on the backend. Used for debugging purposes | `{}` | -| `backend.persistence.volume-name.size` | Size of the additional volume | | -| `backend.persistence.volume-name.type` | Type of the additional volume, persistentVolumeClaim or emptyDir | | -| `backend.persistence.volume-name.mountPath` | Path where the volume should be mounted to | | -| `backend.extraVolumeMounts` | Additional volumes to mount on the backend. | `[]` | -| `backend.extraVolumes` | Additional volumes to mount on the backend. | `[]` | -| `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` | +| Name | Description | Value | +| ----------------------------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `backend.command` | Override the backend container command | `[]` | +| `backend.args` | Override the backend container args | `[]` | +| `backend.replicas` | Amount of backend replicas | `3` | +| `backend.shareProcessNamespace` | Enable share process namespace between containers | `false` | +| `backend.sidecars` | Add sidecars containers to backend deployment | `[]` | +| `backend.migrateJobAnnotations` | Annotations for the migrate job | `{}` | +| `backend.jobs.ttlSecondsAfterFinished` | Period to wait before remove jobs | `30` | +| `backend.jobs.backoffLimit` | Numbers of jobs retries | `2` | +| `backend.securityContext` | Configure backend Pod security context | `nil` | +| `backend.envVars` | Configure backend container environment variables | `undefined` | +| `backend.envVars.BY_VALUE` | Example environment variable by setting value directly | | +| `backend.envVars.FROM_CONFIGMAP.configMapKeyRef.name` | Name of a ConfigMap when configuring env vars from a ConfigMap | | +| `backend.envVars.FROM_CONFIGMAP.configMapKeyRef.key` | Key within a ConfigMap when configuring env vars from a ConfigMap | | +| `backend.envVars.FROM_SECRET.secretKeyRef.name` | Name of a Secret when configuring env vars from a Secret | | +| `backend.envVars.FROM_SECRET.secretKeyRef.key` | Key within a Secret when configuring env vars from a Secret | | +| `backend.podAnnotations` | Annotations to add to the backend Pod | `{}` | +| `backend.dpAnnotations` | Annotations to add to the backend Deployment | `{}` | +| `backend.service.type` | backend Service type | `ClusterIP` | +| `backend.service.port` | backend Service listening port | `80` | +| `backend.service.targetPort` | backend container listening port | `8000` | +| `backend.service.annotations` | Annotations to add to the backend Service | `{}` | +| `backend.migrate.command` | backend migrate command | `["/bin/sh","-c","while ! python manage.py check --database default > /dev/null 2>&1\ndo\n echo \"Database not ready\"\n sleep 2\ndone\n\necho \"Database is ready\"\n\npython manage.py migrate --no-input\n"]` | +| `backend.migrate.restartPolicy` | backend migrate job restart policy | `Never` | +| `backend.createsuperuser.command` | backend migrate command | `["/bin/sh","-c","while ! python manage.py check --database default > /dev/null 2>&1\ndo\n echo \"Database not ready\"\n sleep 2\ndone\n\necho \"Database is ready\"\n\npython manage.py createsuperuser --email $DJANGO_SUPERUSER_EMAIL --password $DJANGO_SUPERUSER_PASSWORD\n"]` | +| `backend.createsuperuser.restartPolicy` | backend migrate job restart policy | `Never` | +| `backend.job` | job dedicated to run a random management command, for example after a deployment | | +| `backend.job.name` | The name to use to describe this job | `""` | +| `backend.job.command` | The management command to execute | `[]` | +| `backend.job.restartPolicy` | The restart policy for the job. | `Never` | +| `backend.job.annotations` | Annotations to add to the job [default: argocd.argoproj.io/hook: PostSync] | | +| `backend.probes.liveness.path` | Configure path for backend HTTP liveness probe | `/__heartbeat__` | +| `backend.probes.liveness.targetPort` | Configure port for backend HTTP liveness probe | `undefined` | +| `backend.probes.liveness.initialDelaySeconds` | Configure initial delay for backend liveness probe | `10` | +| `backend.probes.liveness.initialDelaySeconds` | Configure timeout for backend liveness probe | `10` | +| `backend.probes.startup.path` | Configure path for backend HTTP startup probe | `undefined` | +| `backend.probes.startup.targetPort` | Configure port for backend HTTP startup probe | `undefined` | +| `backend.probes.startup.initialDelaySeconds` | Configure initial delay for backend startup probe | `undefined` | +| `backend.probes.startup.initialDelaySeconds` | Configure timeout for backend startup probe | `undefined` | +| `backend.probes.readiness.path` | Configure path for backend HTTP readiness probe | `/__lbheartbeat__` | +| `backend.probes.readiness.targetPort` | Configure port for backend HTTP readiness probe | `undefined` | +| `backend.probes.readiness.initialDelaySeconds` | Configure initial delay for backend readiness probe | `10` | +| `backend.probes.readiness.initialDelaySeconds` | Configure timeout for backend readiness probe | `10` | +| `backend.resources` | Resource requirements for the backend container | `{}` | +| `backend.nodeSelector` | Node selector for the backend Pod | `{}` | +| `backend.tolerations` | Tolerations for the backend Pod | `[]` | +| `backend.affinity` | Affinity for the backend Pod | `{}` | +| `backend.persistence` | Additional volumes to create and mount on the backend. Used for debugging purposes | `{}` | +| `backend.persistence.volume-name.size` | Size of the additional volume | | +| `backend.persistence.volume-name.type` | Type of the additional volume, persistentVolumeClaim or emptyDir | | +| `backend.persistence.volume-name.mountPath` | Path where the volume should be mounted to | | +| `backend.extraVolumeMounts` | Additional volumes to mount on the backend. | `[]` | +| `backend.extraVolumes` | Additional volumes to mount on the backend. | `[]` | +| `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/impress/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/backend_job_createsuperuser.yaml b/src/helm/impress/templates/backend_job_createsuperuser.yaml index beb7d65e..be159c0f 100644 --- a/src/helm/impress/templates/backend_job_createsuperuser.yaml +++ b/src/helm/impress/templates/backend_job_createsuperuser.yaml @@ -14,6 +14,8 @@ metadata: labels: {{- include "impress.common.labels" (list . $component) | nindent 4 }} spec: + ttlSecondsAfterFinished: {{ .Values.backend.jobs.ttlSecondsAfterFinished }} + backoffLimit: {{ .Values.backend.jobs.backoffLimit }} template: metadata: annotations: diff --git a/src/helm/impress/templates/backend_job_migrate.yaml b/src/helm/impress/templates/backend_job_migrate.yaml index 9c81d7df..00ff9529 100644 --- a/src/helm/impress/templates/backend_job_migrate.yaml +++ b/src/helm/impress/templates/backend_job_migrate.yaml @@ -14,6 +14,8 @@ metadata: labels: {{- include "impress.common.labels" (list . $component) | nindent 4 }} spec: + ttlSecondsAfterFinished: {{ .Values.backend.jobs.ttlSecondsAfterFinished }} + backoffLimit: {{ .Values.backend.jobs.backoffLimit }} template: metadata: annotations: diff --git a/src/helm/impress/values.yaml b/src/helm/impress/values.yaml index f743f02d..69e24caf 100644 --- a/src/helm/impress/values.yaml +++ b/src/helm/impress/values.yaml @@ -201,6 +201,12 @@ backend: ## @param backend.migrateJobAnnotations Annotations for the migrate job migrateJobAnnotations: {} + ## @param backend.jobs.ttlSecondsAfterFinished Period to wait before remove jobs + ## @param backend.jobs.backoffLimit Numbers of jobs retries + jobs: + ttlSecondsAfterFinished: 30 + backoffLimit: 2 + ## @param backend.securityContext Configure backend Pod security context securityContext: null @@ -234,10 +240,18 @@ backend: ## @param backend.migrate.restartPolicy backend migrate job restart policy migrate: command: - - "python" - - "manage.py" - - "migrate" - - "--no-input" + - /bin/sh + - "-c" + - | + while ! python manage.py check --database default > /dev/null 2>&1 + do + echo "Database not ready" + sleep 2 + done + + echo "Database is ready" + + python manage.py migrate --no-input restartPolicy: Never ## @param backend.createsuperuser.command backend migrate command @@ -247,6 +261,14 @@ backend: - "/bin/sh" - "-c" - | + while ! python manage.py check --database default > /dev/null 2>&1 + do + echo "Database not ready" + sleep 2 + done + + echo "Database is ready" + python manage.py createsuperuser --email $DJANGO_SUPERUSER_EMAIL --password $DJANGO_SUPERUSER_PASSWORD restartPolicy: Never