From f9d48e46afdf2a4b1ba488b4bc830d9f21d0d045 Mon Sep 17 00:00:00 2001 From: Jacob McSwain <jacob.a.mcswain@gmail.com> Date: Tue, 20 Feb 2024 20:20:06 -0600 Subject: [PATCH] feat: make container lifecycle configurable (#17) # Motivations I would like to send custom broadcast messages from the pre-stop hook. # Modifications - This PR moves the current Deployment's container `lifecycle` to the values under `server.lifecycle` and makes the default the previous default values - Makes the `terminationGracePeriodSeconds` configurable to allow long-running `preStop` lifecycle hooks --- charts/palworld/templates/deployments.yaml | 10 ++++------ charts/palworld/values.yaml | 10 ++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/charts/palworld/templates/deployments.yaml b/charts/palworld/templates/deployments.yaml index 5b2a8ab..6439e77 100644 --- a/charts/palworld/templates/deployments.yaml +++ b/charts/palworld/templates/deployments.yaml @@ -41,13 +41,10 @@ spec: - name: server image: "{{ .Values.server.image.repository }}:{{ .Values.server.image.tag }}" imagePullPolicy: {{ .Values.server.image.imagePullPolicy }} + {{- with .Values.server.lifecycle }} lifecycle: - preStop: - exec: - command: - - "sh" - - "-c" - - rcon-cli save && backup + {{- toYaml . | nindent 12 }} + {{- end }} resources: {{- with .Values.server.resources }} {{- toYaml . | nindent 12 }} @@ -93,6 +90,7 @@ spec: volumeMounts: - mountPath: /palworld name: datadir + terminationGracePeriodSeconds: {{ .Values.server.terminationGracePeriodSeconds }} {{- with .Values.server.image.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} diff --git a/charts/palworld/values.yaml b/charts/palworld/values.yaml index 5929bfb..db2fd6e 100644 --- a/charts/palworld/values.yaml +++ b/charts/palworld/values.yaml @@ -69,6 +69,16 @@ server: # - rcon-cli Info | grep -q "Welcome to Pal Server" # initialDelaySeconds: 60 + # Container lifecycle + terminationGracePeriodSeconds: 30 + lifecycle: + preStop: + exec: + command: + - "sh" + - "-c" + - rcon-cli save && backup + # Service configuration # service: