Skip to content

Commit 4606e49

Browse files
bjgiraudonalambare
andauthored
chore(helm): add hpa, terminationGracePeriodSeconds, deployment annotations (#53)
This PR enhances the `stac-fastapi-eodag` Helm chart with improved deployment configuration options and comprehensive deployment documentation. # 🔧 Configuration Improvements - Added configurable `terminationGracePeriodSeconds`: Allows customization of pod termination grace period through Helm values - Added `HorizontalPodAutoscaler` # 📚 Documentation - Added [DEPLOYMENT.md](https://github.com/CS-SI/stac-fastapi-eodag/blob/fix/deployment/helm/stac-fastapi-eodag/DEPLOYMENT.md): Comprehensive deployment guide covering: - Automatic configuration reloading with Reloader - Graceful shutdown configuration for long-running operations --------- Signed-off-by: Aubin Lambaré <aubin.lambare@cs-soprasteria.com> Co-authored-by: LAMBARE Aubin <aubin.lambare@cs-soprasteria.com>
1 parent e9da406 commit 4606e49

7 files changed

Lines changed: 140 additions & 11 deletions

File tree

helm/stac-fastapi-eodag/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
- name: common
33
repository: oci://registry-1.docker.io/bitnamicharts
4-
version: 2.30.0
5-
digest: sha256:46afdf79eae69065904d430f03f7e5b79a148afed20aa45ee83ba88adc036169
6-
generated: "2025-03-12T15:42:59.908620573+01:00"
4+
version: 2.31.4
5+
digest: sha256:fc442e77200e1914dd46fe26490dcf62f44caa51db673c2f8e67d5319cd4c163
6+
generated: "2025-09-24T14:55:49.710744284+02:00"

helm/stac-fastapi-eodag/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ name: stac-fastapi-eodag
2222
sources:
2323
- https://github.com/CS-SI/stac-fastapi-eodag
2424
type: application
25-
version: 0.1.0
25+
version: 0.3.0
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Deployment Guide for stac-fastapi-eodag
2+
3+
This document provides guidance on deploying stac-fastapi-eodag in production environments, with specific focus on configuration management and graceful shutdowns.
4+
5+
## Automatic Configuration Reloading with Reloader
6+
7+
The stac-fastapi-eodag Helm chart supports automatic configuration reloading using [Reloader](https://github.com/stakater/Reloader). This allows pods to be automatically restarted when ConfigMaps or Secrets are updated.
8+
9+
### Available Reloader Annotations
10+
11+
| Annotation | Purpose | Example |
12+
|------------|---------|---------|
13+
| `configmap.reloader.stakater.com/reload` | Restart pods when specified ConfigMaps change | `"config-name1,config-name2"` |
14+
| `secret.reloader.stakater.com/reload` | Restart pods when specified Secrets change | `"secret-name1,secret-name2"` |
15+
| `reloader.stakater.com/auto` | Auto-discover and reload on any ConfigMap/Secret change | `"true"` |
16+
17+
### Example Configuration
18+
19+
```yaml
20+
# values.yaml
21+
deployment:
22+
annotations:
23+
# Reload when main config changes
24+
configmap.reloader.stakater.com/reload: "stac-fastapi-eodag-config,data-repo-commit-hash"
25+
# Reload when credentials change
26+
secret.reloader.stakater.com/reload: "eodag-server-credentials"
27+
```
28+
29+
### Installing Reloader
30+
31+
If Reloader is not already installed in your cluster, you can install it using:
32+
33+
```bash
34+
# Using Helm
35+
helm repo add stakater https://stakater.github.io/stakater-charts
36+
helm repo update
37+
helm install reloader stakater/reloader
38+
39+
# Or using kubectl
40+
kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml
41+
```
42+
43+
## Graceful Shutdown with terminationGracePeriodSeconds
44+
45+
The `terminationGracePeriodSeconds` parameter controls how long Kubernetes waits before forcefully killing a pod during shutdown. This is crucial for stac-fastapi-eodag when handling long-running operations like data downloads.
46+
47+
### Configuring Termination Grace Period
48+
49+
```yaml
50+
# values.yaml
51+
# Default Kubernetes value is 30 seconds
52+
terminationGracePeriodSeconds: 7200 # 2 hours for long downloads
53+
```
54+
55+
### Troubleshooting
56+
57+
If pods are being forcefully killed:
58+
59+
1. **Increase Grace Period**: Adjust `terminationGracePeriodSeconds`
60+
2. **Check Application Logs**: Ensure the app handles SIGTERM
61+
3. **Monitor Resource Usage**: High CPU/memory might slow shutdown
62+
4. **Review Health Checks**: Ensure probes don't interfere with shutdown

helm/stac-fastapi-eodag/templates/deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ metadata:
1212
{{- if .Values.commonLabels }}
1313
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
1414
{{- end }}
15+
{{- if or .Values.commonAnnotations .Values.deployment.annotations }}
16+
annotations:
1517
{{- if .Values.commonAnnotations }}
16-
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
18+
{{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
19+
{{- end }}
20+
{{- if .Values.deployment.annotations }}
21+
{{- include "common.tplvalues.render" (dict "value" .Values.deployment.annotations "context" $) | nindent 4 }}
22+
{{- end }}
1723
{{- end }}
1824
spec:
1925
replicas: {{ .Values.replicaCount }}
@@ -76,6 +82,7 @@ spec:
7682
{{- if .Values.podSecurityContext.enabled }}
7783
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
7884
{{- end }}
85+
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
7986
{{- with .Values.imagePullSecrets }}
8087
imagePullSecrets:
8188
{{- toYaml . | nindent 8 }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if .Values.horizontalPodAutoscaler.enabled -}}
2+
{{- if not .Values.resources.requests }}
3+
{{- fail "resources.requests is required if horizontalPodAutoscaler is enabled" -}}
4+
{{- end }}
5+
apiVersion: autoscaling/v2
6+
kind: HorizontalPodAutoscaler
7+
metadata:
8+
name: {{ include "common.names.fullname" . }}
9+
namespace: {{ include "common.names.namespace" . | quote }}
10+
labels: {{- include "common.labels.standard" . | nindent 4 }}
11+
{{- if .Values.commonLabels }}
12+
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
13+
{{- end }}
14+
{{- if .Values.commonAnnotations }}
15+
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
scaleTargetRef:
19+
apiVersion: apps/v1
20+
kind: Deployment
21+
name: {{ include "common.names.fullname" . }}
22+
minReplicas: {{ .Values.replicaCount }}
23+
maxReplicas: {{ .Values.horizontalPodAutoscaler.maxReplicas }}
24+
metrics:
25+
{{- if .Values.horizontalPodAutoscaler.cpuUtilization }}
26+
- type: Resource
27+
resource:
28+
name: cpu
29+
target:
30+
type: Utilization
31+
averageUtilization: {{ .Values.horizontalPodAutoscaler.cpuUtilization }}
32+
{{- end }}
33+
{{- if .Values.horizontalPodAutoscaler.memUtilization }}
34+
- type: Resource
35+
resource:
36+
name: memory
37+
target:
38+
type: Utilization
39+
averageUtilization: {{ .Values.horizontalPodAutoscaler.memUtilization }}
40+
{{- end }}
41+
{{- end -}}

helm/stac-fastapi-eodag/templates/ingress.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ metadata:
2323
{{- end }}
2424
{{- end }}
2525
spec:
26-
{{- if and .Values.ingress.ingressClassName (eq "true" (include "common.ingress.supportsIngressClassname" .)) }}
26+
{{- if .Values.ingress.ingressClassName }}
2727
ingressClassName: {{ .Values.ingress.ingressClassName | quote }}
2828
{{- end }}
2929
rules:
@@ -35,19 +35,15 @@ spec:
3535
{{- toYaml .Values.ingress.extraPaths | nindent 10 }}
3636
{{- end }}
3737
- path: {{ .Values.ingress.path }}
38-
{{- if eq "true" (include "common.ingress.supportsPathType" .) }}
3938
pathType: {{ .Values.ingress.pathType }}
40-
{{- end }}
4139
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" .) "servicePort" .Values.ingress.servicePort "context" $) | nindent 14 }}
4240
{{- end }}
4341
{{- range .Values.ingress.extraHosts }}
4442
- host: {{ .name | quote }}
4543
http:
4644
paths:
4745
- path: {{ default "/" .path }}
48-
{{- if eq "true" (include "common.ingress.supportsPathType" $) }}
4946
pathType: {{ default "ImplementationSpecific" .pathType }}
50-
{{- end }}
5147
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" $) "servicePort" .Values.ingress.servicePort "context" $) | nindent 14 }}
5248
{{- end }}
5349
{{- if .Values.ingress.extraRules }}

helm/stac-fastapi-eodag/values.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,19 @@ resources:
288288
limits: {}
289289
requests: {}
290290

291+
## STAC FastAPI EODAG horizontal autoscaling
292+
## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
293+
## @param horizontalPodAutoscaler.enabled Decide to enable or disable the horizontal pod autoscaler
294+
## @param horizontalPodAutoscaler.maxReplicas The maximum number of replicas that are allowed to run simultaneously
295+
## @param horizontalPodAutoscaler.cpuUtilization The maximum CPU utilization target computed in % of the CPU resources request.
296+
## @param horizontalPodAutoscaler.memUtilization The maximum RAM utilization target computed in % of the RAM resources request.
297+
##
298+
horizontalPodAutoscaler:
299+
enabled: false
300+
maxReplicas: 10
301+
cpuUtilization: 50
302+
memUtilization: 50
303+
291304
## Configure Pods Security Context
292305
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
293306
## @param podSecurityContext.enabled Enabled stac-fastapi-eodag pods' Security Context
@@ -426,6 +439,11 @@ priorityClassName: ""
426439
##
427440
runtimeClassName: ""
428441

442+
## @param terminationGracePeriodSeconds Termination grace period in seconds for pods
443+
## This allows pods to gracefully shut down before being forcefully terminated
444+
##
445+
terminationGracePeriodSeconds: 30
446+
429447
## @param lifecycleHooks for the stac-fastapi-eodag container(s) to automate configuration before or after startup
430448
##
431449
lifecycleHooks: {}
@@ -477,6 +495,11 @@ sidecars: []
477495
##
478496
initContainers: []
479497

498+
## Deployment configuration
499+
deployment:
500+
## @param deployment.annotations Additional custom annotations for stac-fastapi-eodag deployment
501+
annotations: {}
502+
480503
## Service configuration
481504
##
482505
service:
@@ -663,7 +686,7 @@ serviceAccount:
663686
annotations: {}
664687
## @param serviceAccount.automountServiceAccountToken Automount service account token for the server service account
665688
##
666-
automountServiceAccountToken: false
689+
automountServiceAccountToken: true
667690

668691

669692
## @section Telemetry parameters

0 commit comments

Comments
 (0)