Skip to content

Commit acc1c88

Browse files
committed
feat(k8s): Add readiness and liveness probes
Add HEALTHCHECK in backend Dockerfile while at it
1 parent 9c67040 commit acc1c88

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

backend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ USER nonroot
3636

3737
EXPOSE 8000
3838

39+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
40+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
41+
3942
# Run the FastAPI application by default
4043
CMD ["python", "-m", "src.main"]

k8s/backend/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ spec:
2626
limits:
2727
cpu: 500m
2828
memory: 256Mi
29+
readinessProbe:
30+
httpGet:
31+
path: /health
32+
port: 8000
33+
initialDelaySeconds: 5
34+
periodSeconds: 5
35+
livenessProbe:
36+
httpGet:
37+
path: /health
38+
port: 8000
39+
initialDelaySeconds: 10
40+
periodSeconds: 10

k8s/frontend/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ spec:
2626
limits:
2727
cpu: 200m
2828
memory: 128Mi
29+
readinessProbe:
30+
httpGet:
31+
path: /
32+
port: 8080
33+
initialDelaySeconds: 2
34+
periodSeconds: 5
35+
livenessProbe:
36+
httpGet:
37+
path: /
38+
port: 8080
39+
initialDelaySeconds: 5
40+
periodSeconds: 10

0 commit comments

Comments
 (0)