Skip to content

Commit

Permalink
Add ingress.shutdownDelaySeconds
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Oct 11, 2024
1 parent 2ac4372 commit 4a8f6da
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions charts/generic-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
6 changes: 3 additions & 3 deletions charts/generic-service/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
5 changes: 5 additions & 0 deletions charts/generic-service/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions charts/generic-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ additionalMounts: {}

ingress:
enabled: false
shutdownDelaySeconds: 5
port: 80
protocol: http
timeoutSeconds: null
Expand Down

0 comments on commit 4a8f6da

Please sign in to comment.