Skip to content

Commit 84c2a37

Browse files
Clément VALENTINclaude
andcommitted
feat: ajouter init containers pour gérer l'ordre de démarrage
- Backend attend PostgreSQL et Redis avant de démarrer - Frontend attend Backend avant de démarrer - Utilise busybox avec netcat pour vérifier la connectivité 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 46a4269 commit 84c2a37

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

helm/myelectricaldata/templates/backend/backend-deployment.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ spec:
2929
securityContext:
3030
{{- toYaml . | nindent 8 }}
3131
{{- end }}
32+
initContainers:
33+
# Wait for PostgreSQL to be ready
34+
{{- if .Values.postgres.enabled }}
35+
- name: wait-for-postgres
36+
image: busybox:1.36
37+
command: ['sh', '-c', 'until nc -z {{ .Release.Name }}-postgres {{ .Values.postgres.service.port | default 5432 }}; do echo "Waiting for PostgreSQL..."; sleep 2; done; echo "PostgreSQL is ready!"']
38+
{{- end }}
39+
# Wait for Redis to be ready
40+
{{- if .Values.redis.enabled }}
41+
- name: wait-for-redis
42+
image: busybox:1.36
43+
command: ['sh', '-c', 'until nc -z {{ .Release.Name }}-redis {{ .Values.redis.service.port | default 6379 }}; do echo "Waiting for Redis..."; sleep 2; done; echo "Redis is ready!"']
44+
{{- end }}
3245
containers:
3346
- name: backend
3447
{{- with .Values.backend.securityContext }}

helm/myelectricaldata/templates/frontend/frontend-deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ spec:
2525
securityContext:
2626
{{- toYaml . | nindent 8 }}
2727
{{- end }}
28+
initContainers:
29+
# Wait for backend to be ready
30+
{{- if .Values.backend.enabled }}
31+
- name: wait-for-backend
32+
image: busybox:1.36
33+
command: ['sh', '-c', 'until nc -z {{ include "myelectricaldata.backend.fullname" . }} {{ .Values.backend.service.port | default 8000 }}; do echo "Waiting for Backend..."; sleep 2; done; echo "Backend is ready!"']
34+
{{- end }}
2835
containers:
2936
- name: frontend
3037
{{- with .Values.frontend.securityContext }}

0 commit comments

Comments
 (0)