diff --git a/charts/generic-service/README.md b/charts/generic-service/README.md index a7a305e..d51408b 100644 --- a/charts/generic-service/README.md +++ b/charts/generic-service/README.md @@ -98,6 +98,7 @@ app: | `additionalMounts.PATH.name` | __required if used__ | The name of an additional volume to be mounted at `PATH` inside the container | | `additionalMounts.PATH.*` | __required if used__ | The configuration for the additional volume (e.g., `emptyDir: {}`) | | `ingress.enabled` | `false` | Enables ingress into the service (either cluster-internal or public) | +| `ingress.shutdownDelaySeconds` | `5` | The number of seconds to delay shutting down the container once no new requests are being routed to it | | `ingress.port` | `80` | The container port ingress traffic is routed to | | `ingress.protocol` | `http` | The internal protocol used for ingress (e.g., `http`, `https`, `h2c`, `grpc`, `http2`/`h2` or `grpcs`) | | `ingress.timeoutSeconds` | | Number of seconds after which to timeout waiting for response from service; -1 for infinite | diff --git a/charts/generic-service/templates/controller.yaml b/charts/generic-service/templates/controller.yaml index 15dd991..0e57cb7 100644 --- a/charts/generic-service/templates/controller.yaml +++ b/charts/generic-service/templates/controller.yaml @@ -194,7 +194,7 @@ spec: serviceAccountName: '{{ .Values.rbac.existingServiceAccount | default (include "generic-service.fullname" .) }}' {{- end }} - terminationGracePeriodSeconds: {{ .Values.maxShutdownSeconds | int }} + terminationGracePeriodSeconds: {{ if and .Values.ingress.enabled .Values.ingress.shutdownDelaySeconds }}{{ add (.Values.maxShutdownSeconds | int) (.Values.ingress.shutdownDelaySeconds | int) }}{{ else }}{{ .Values.maxShutdownSeconds | int }}{{ end }} {{- if .Values.scheduling.priority }} priorityClassName: {{ .Values.scheduling.priority }} @@ -434,12 +434,12 @@ spec: {{ if $val }}value: {{ $val | quote }}{{ end }} {{- end }} - {{- if and .Values.ingress.enabled .Values.maxShutdownSeconds | int }} + {{- if and .Values.ingress.enabled .Values.ingress.shutdownDelaySeconds }} # Delay shutdown to give ingress controller time to reroute traffic lifecycle: preStop: exec: - command: ["sleep", "5"] + command: ["sleep", "{{ .Values.ingress.shutdownDelaySeconds }}"] {{- end }} {{- range .Values.sidecars }} diff --git a/charts/generic-service/values.schema.json b/charts/generic-service/values.schema.json index eeb3f80..6ca6e12 100644 --- a/charts/generic-service/values.schema.json +++ b/charts/generic-service/values.schema.json @@ -680,6 +680,11 @@ "default": false, "description": "Enables ingress into the service (either cluster-internal or public)" }, + "shutdownDelaySeconds": { + "type": "integer", + "default": 5, + "description": "The number of seconds to delay shutting down the container once no new requests are being routed to it" + }, "port": { "type": "integer", "default": 80, diff --git a/charts/generic-service/values.yaml b/charts/generic-service/values.yaml index 09d1026..b442e5e 100644 --- a/charts/generic-service/values.yaml +++ b/charts/generic-service/values.yaml @@ -105,6 +105,7 @@ additionalMounts: {} ingress: enabled: false + shutdownDelaySeconds: 5 port: 80 protocol: http timeoutSeconds: null