🚸(helm) improve helm chart

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.
This commit is contained in:
Jacques ROUSSEL
2025-06-05 16:40:33 +02:00
committed by Manuel Raynaud
parent 080f855083
commit a83902a0d4
6 changed files with 114 additions and 71 deletions

View File

@@ -68,6 +68,14 @@ backend:
- "/bin/sh" - "/bin/sh"
- "-c" - "-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 migrate --no-input &&
python manage.py create_demo --force python manage.py create_demo --force
restartPolicy: Never restartPolicy: Never
@@ -84,6 +92,13 @@ backend:
- "/bin/sh" - "/bin/sh"
- "-c" - "-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 python manage.py createsuperuser --email admin@example.com --password admin
restartPolicy: Never restartPolicy: Never

View File

@@ -1,5 +1,5 @@
apiVersion: v2 apiVersion: v2
type: application type: application
name: docs name: docs
version: 3.3.0 version: 3.4.0-beta.1
appVersion: latest appVersion: latest

View File

@@ -80,13 +80,15 @@
### backend ### backend
| Name | Description | Value | | Name | Description | Value |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | ----------------------------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `backend.command` | Override the backend container command | `[]` | | `backend.command` | Override the backend container command | `[]` |
| `backend.args` | Override the backend container args | `[]` | | `backend.args` | Override the backend container args | `[]` |
| `backend.replicas` | Amount of backend replicas | `3` | | `backend.replicas` | Amount of backend replicas | `3` |
| `backend.shareProcessNamespace` | Enable share process namespace between containers | `false` | | `backend.shareProcessNamespace` | Enable share process namespace between containers | `false` |
| `backend.sidecars` | Add sidecars containers to backend deployment | `[]` | | `backend.sidecars` | Add sidecars containers to backend deployment | `[]` |
| `backend.migrateJobAnnotations` | Annotations for the migrate job | `{}` | | `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.securityContext` | Configure backend Pod security context | `nil` |
| `backend.envVars` | Configure backend container environment variables | `undefined` | | `backend.envVars` | Configure backend container environment variables | `undefined` |
| `backend.envVars.BY_VALUE` | Example environment variable by setting value directly | | | `backend.envVars.BY_VALUE` | Example environment variable by setting value directly | |
@@ -100,9 +102,9 @@
| `backend.service.port` | backend Service listening port | `80` | | `backend.service.port` | backend Service listening port | `80` |
| `backend.service.targetPort` | backend container listening port | `8000` | | `backend.service.targetPort` | backend container listening port | `8000` |
| `backend.service.annotations` | Annotations to add to the backend Service | `{}` | | `backend.service.annotations` | Annotations to add to the backend Service | `{}` |
| `backend.migrate.command` | backend migrate command | `["python","manage.py","migrate","--no-input"]` | | `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.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.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.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` | 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.name` | The name to use to describe this job | `""` |
@@ -134,7 +136,7 @@
| `backend.pdb.enabled` | Enable pdb on backend | `true` | | `backend.pdb.enabled` | Enable pdb on backend | `true` |
| `backend.themeCustomization.enabled` | Enable theme customization | `false` | | `backend.themeCustomization.enabled` | Enable theme customization | `false` |
| `backend.themeCustomization.file_content` | Content of the theme customization file. Must be a json object. | `""` | | `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.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.replicas` | Amount of celery replicas | `1` |
| `backend.celery.command` | Override the celery container command | `[]` | | `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.args` | Override the celery container args | `["celery","-A","impress.celery_app","worker","-l","INFO","-n","impress@%h"]` |

View File

@@ -14,6 +14,8 @@ metadata:
labels: labels:
{{- include "impress.common.labels" (list . $component) | nindent 4 }} {{- include "impress.common.labels" (list . $component) | nindent 4 }}
spec: spec:
ttlSecondsAfterFinished: {{ .Values.backend.jobs.ttlSecondsAfterFinished }}
backoffLimit: {{ .Values.backend.jobs.backoffLimit }}
template: template:
metadata: metadata:
annotations: annotations:

View File

@@ -14,6 +14,8 @@ metadata:
labels: labels:
{{- include "impress.common.labels" (list . $component) | nindent 4 }} {{- include "impress.common.labels" (list . $component) | nindent 4 }}
spec: spec:
ttlSecondsAfterFinished: {{ .Values.backend.jobs.ttlSecondsAfterFinished }}
backoffLimit: {{ .Values.backend.jobs.backoffLimit }}
template: template:
metadata: metadata:
annotations: annotations:

View File

@@ -201,6 +201,12 @@ backend:
## @param backend.migrateJobAnnotations Annotations for the migrate job ## @param backend.migrateJobAnnotations Annotations for the migrate job
migrateJobAnnotations: {} 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 ## @param backend.securityContext Configure backend Pod security context
securityContext: null securityContext: null
@@ -234,10 +240,18 @@ backend:
## @param backend.migrate.restartPolicy backend migrate job restart policy ## @param backend.migrate.restartPolicy backend migrate job restart policy
migrate: migrate:
command: command:
- "python" - /bin/sh
- "manage.py" - "-c"
- "migrate" - |
- "--no-input" 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 restartPolicy: Never
## @param backend.createsuperuser.command backend migrate command ## @param backend.createsuperuser.command backend migrate command
@@ -247,6 +261,14 @@ backend:
- "/bin/sh" - "/bin/sh"
- "-c" - "-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 python manage.py createsuperuser --email $DJANGO_SUPERUSER_EMAIL --password $DJANGO_SUPERUSER_PASSWORD
restartPolicy: Never restartPolicy: Never