diff --git a/charts/agent/templates/deployment.yaml b/charts/agent/templates/deployment.yaml index 33b37e9..b5996e6 100644 --- a/charts/agent/templates/deployment.yaml +++ b/charts/agent/templates/deployment.yaml @@ -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: @@ -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 }} diff --git a/charts/agent/values.yaml b/charts/agent/values.yaml index 0266e2a..786302c 100644 --- a/charts/agent/values.yaml +++ b/charts/agent/values.yaml @@ -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" @@ -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: