Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions charts/agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ spec:
{{- end }}

spec:
{{- if .Values.gracefulShutdown.enabled }}
terminationGracePeriodSeconds: {{ .Values.gracefulShutdown.terminationGracePeriodSeconds }}
{{- end }}
priorityClassName: nullplatform-critical-{{ .Release.Name }}
serviceAccountName: {{ include "agent.serviceAccountName" . }}
securityContext:
Expand Down Expand Up @@ -62,8 +65,20 @@ spec:
envFrom:
- secretRef:
name: {{ .Values.configuration.secretName }}-{{ .Release.Name }}
{{- if .Values.gracefulShutdown.enabled }}
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- |
echo "$(date): Initiating graceful shutdown..." >> /tmp/shutdown.log
sleep {{ .Values.gracefulShutdown.preStopDelay }}
{{- else }}
lifecycle:
{{- toYaml .Values.lifecycle | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
Expand Down
10 changes: 8 additions & 2 deletions charts/agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace: nullplatform-tools
args:
- "--tags=$(TAGS)"
- "--apikey=$(NP_API_KEY)"
- "--runtime=host"
- "--runtime=k8s"
- "--command-executor-env=NP_API_KEY=$(NP_API_KEY)"
- "--command-executor-debug"
- "--webserver-enabled"
Expand Down Expand Up @@ -111,7 +111,13 @@ initScripts: []
# Additional volumeMounts on the output Deployment definition.
volumeMounts: []

#Lifecycle preStop Hook for Graceful Agent Shutdown
# Graceful shutdown configuration
gracefulShutdown:
enabled: true
terminationGracePeriodSeconds: 900
preStopDelay: 2

# Legacy lifecycle configuration (used when gracefulShutdown.enabled is false)
lifecycle:
preStop:
exec:
Expand Down