Skip to content

Commit

Permalink
[Helm] Add the ability to specify container lifecycle (#8010)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:

Add the ability to specify container lifecycle in helm chart. This is
useful when pods are served by a load balancer that needs time to
deregister terminating pods, as we can setup a preStop hook to wait a
bit before terminating the container. Example:

```yaml
gateway:
  lifecycle:
    preStop:
      exec:
        command: ["/bin/sh", "-c", "sleep 30"]
```

**Which issue(s) this PR fixes**:
None

**Special notes for your reviewer**:
None

**Checklist**
- [x] Reviewed the `CONTRIBUTING.md` guide
- [x] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`
  • Loading branch information
Quentin Plessis committed Jan 4, 2023
1 parent 2a2d1f9 commit fde4460
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 2 deletions.
27 changes: 27 additions & 0 deletions docs/sources/installation/helm/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,15 @@ false
}
]
</pre>
</td>
</tr>
<tr>
<td>gateway.lifecycle</td>
<td>object</td>
<td>Lifecycle for the gateway container</td>
<td><pre lang="json">
{}
</pre>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -2457,6 +2466,15 @@ null
<td><pre lang="json">
null
</pre>
</td>
</tr>
<tr>
<td>read.lifecycle</td>
<td>object</td>
<td>Lifecycle for the read container</td>
<td><pre lang="json">
{}
</pre>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -3059,6 +3077,15 @@ null
<td><pre lang="json">
null
</pre>
</td>
</tr>
<tr>
<td>write.lifecycle</td>
<td>object</td>
<td>Lifecycle for the write container</td>
<td><pre lang="json">
{}
</pre>
</td>
</tr>
<tr>
Expand Down
4 changes: 4 additions & 0 deletions production/helm/loki/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Entries should be ordered as follows:

Entries should include a reference to the pull request that introduced the change.

## 3.8.1

- [ENHANCEMENT] Add the ability to specify container lifecycle

## 3.8.0

- [BUGFIX] Added `helm-weight` annotations to the tokengen and provisioner jobs to make sure tokengen always runs before provisioner
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: loki
description: Helm chart for Grafana Loki in simple, scalable mode
type: application
appVersion: 2.7.0
version: 3.8.0
version: 3.8.1
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# loki

![Version: 3.8.0](https://img.shields.io/badge/Version-3.8.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.7.0](https://img.shields.io/badge/AppVersion-2.7.0-informational?style=flat-square)
![Version: 3.8.1](https://img.shields.io/badge/Version-3.8.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.7.0](https://img.shields.io/badge/AppVersion-2.7.0-informational?style=flat-square)

Helm chart for Grafana Loki in simple, scalable mode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ spec:
{{- toYaml .Values.gateway.readinessProbe | nindent 12 }}
securityContext:
{{- toYaml .Values.gateway.containerSecurityContext | nindent 12 }}
{{- with .Values.gateway.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/nginx
Expand Down
4 changes: 4 additions & 0 deletions production/helm/loki/templates/read/statefulset-read.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ spec:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
{{- with .Values.read.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
Expand Down
4 changes: 4 additions & 0 deletions production/helm/loki/templates/write/statefulset-write.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
{{- with .Values.write.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
Expand Down
6 changes: 6 additions & 0 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,8 @@ write:
extraEnv: []
# -- Environment variables from secrets or configmaps to add to the write pods
extraEnvFrom: []
# -- Lifecycle for the write container
lifecycle: {}
# -- Volume mounts to add to the write pods
extraVolumeMounts: []
# -- Volumes to add to the write pods
Expand Down Expand Up @@ -826,6 +828,8 @@ read:
extraEnv: []
# -- Environment variables from secrets or configmaps to add to the read pods
extraEnvFrom: []
# -- Lifecycle for the read container
lifecycle: {}
# -- Volume mounts to add to the read pods
extraVolumeMounts: []
# -- Volumes to add to the read pods
Expand Down Expand Up @@ -1012,6 +1016,8 @@ gateway:
extraEnv: []
# -- Environment variables from secrets or configmaps to add to the gateway pods
extraEnvFrom: []
# -- Lifecycle for the gateway container
lifecycle: {}
# -- Volumes to add to the gateway pods
extraVolumes: []
# -- Volume mounts to add to the gateway pods
Expand Down

0 comments on commit fde4460

Please sign in to comment.