Helm: Allow emptyDir data volumes for backend and write (#10338)

**What this PR does / why we need it**:

This enables deployment of write and backend modules using emptyDir in
place of a PersistentVolume for the data volume.

This is useful for Kuberenetes clusters (for example, on-prem) that are
unable to easily provide persistent volumes.

This is intended for use with something like s3 storage where (per
[comment](45b127cfd6/production/helm/loki/templates/backend/statefulset-backend.yaml (L30-L33))
on `persistentVolumeClaimRetentionPolicy`)

> Data on the (write or backend) nodes is easy to replace ... and will
rely on re-fetching data when needed.

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

Fixes #9131

**Special notes for your reviewer**:

If there are other modules this should be applied to, please let me
know.

I'm just getting started with Loki this month and have added only the
modules which come with the default chart (gateway, read, write,
backend) and make persistent volume claims (write, backend).

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added
- ~Tests updated~
  - no tests for modified helm modules found
- ~`CHANGELOG.md` updated~
  - not used for helm changes
- ~If the change is worth mentioning in the release notes, add
`add-to-release-notes` label~
    - unlikely to be noteworthy
- ~Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`~
  - not related to loki upgrade
- [x] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](d10549e3ec)

---------

Co-authored-by: J Stickler <julie.stickler@grafana.com>
Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com>
pull/10622/head helm-loki-5.26.0
Mat Schaffer 2 years ago committed by GitHub
parent fe71c7e9d9
commit 3b4bd12db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      docs/sources/setup/install/helm/reference.md
  2. 4
      production/helm/loki/CHANGELOG.md
  3. 2
      production/helm/loki/Chart.yaml
  4. 2
      production/helm/loki/README.md
  5. 8
      production/helm/loki/templates/backend/statefulset-backend.yaml
  6. 8
      production/helm/loki/templates/write/statefulset-write.yaml
  7. 10
      production/helm/loki/values.yaml

@ -202,6 +202,17 @@ null
<td><pre lang="json">
{}
</pre>
</td>
</tr>
<tr>
<td>backend.persistence.dataVolumeParameters</td>
<td>object</td>
<td>Parameters used for the `data` volume when volumeClaimEnabled if false</td>
<td><pre lang="json">
{
"emptyDir": {}
}
</pre>
</td>
</tr>
<tr>
@ -238,6 +249,15 @@ null
<td><pre lang="json">
null
</pre>
</td>
</tr>
<tr>
<td>backend.persistence.volumeClaimsEnabled</td>
<td>bool</td>
<td>Enable volume claims in pod spec</td>
<td><pre lang="json">
true
</pre>
</td>
</tr>
<tr>
@ -4546,6 +4566,17 @@ null
<td><pre lang="json">
{}
</pre>
</td>
</tr>
<tr>
<td>write.persistence.dataVolumeParameters</td>
<td>object</td>
<td>Parameters used for the `data` volume when volumeClaimEnabled if false</td>
<td><pre lang="json">
{
"emptyDir": {}
}
</pre>
</td>
</tr>
<tr>
@ -4582,6 +4613,15 @@ null
<td><pre lang="json">
null
</pre>
</td>
</tr>
<tr>
<td>write.persistence.volumeClaimsEnabled</td>
<td>bool</td>
<td>Enable volume claims in pod spec</td>
<td><pre lang="json">
true
</pre>
</td>
</tr>
<tr>

@ -13,6 +13,10 @@ Entries should include a reference to the pull request that introduced the chang
[//]: # (<AUTOMATED_UPDATES_LOCATOR> : do not remove this line. This locator is used by the CI pipeline to automatically create a changelog entry for each new Loki release. Add other chart versions and respective changelog entries bellow this line.)
## 5.26.0
- [ENHANCEMENT] Allow emptyDir data volumes for backend and write (via `X.persistence.volumeClaimsEnabled: false`)
## 5.25.0
- [BUGFIX] Add complete object schema to single-binary volumeClaimTemplate to avoid synchronization issues

@ -3,7 +3,7 @@ name: loki
description: Helm chart for Grafana Loki in simple, scalable mode
type: application
appVersion: 2.9.1
version: 5.25.0
version: 5.26.0
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki

@ -1,6 +1,6 @@
# loki
![Version: 5.25.0](https://img.shields.io/badge/Version-5.25.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.1](https://img.shields.io/badge/AppVersion-2.9.1-informational?style=flat-square)
![Version: 5.26.0](https://img.shields.io/badge/Version-5.26.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.1](https://img.shields.io/badge/AppVersion-2.9.1-informational?style=flat-square)
Helm chart for Grafana Loki in simple, scalable mode

@ -28,7 +28,7 @@ spec:
partition: 0
serviceName: {{ include "loki.backendFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.backend.persistence.enableStatefulSetAutoDeletePVC) }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.backend.persistence.enableStatefulSetAutoDeletePVC) (.Values.backend.persistence.volumeClaimsEnabled) }}
{{/*
Data on the backend nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
@ -222,6 +222,10 @@ spec:
volumes:
- name: tmp
emptyDir: {}
{{- if not .Values.backend.persistence.volumeClaimsEnabled }}
- name: data
{{- toYaml .Values.backend.persistence.dataVolumeParameters | nindent 10 }}
{{- end}}
- name: config
{{- if .Values.loki.existingSecretForConfig }}
secret:
@ -253,6 +257,7 @@ spec:
{{- with .Values.backend.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.backend.persistence.volumeClaimsEnabled }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
@ -271,4 +276,5 @@ spec:
selector:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}

@ -28,7 +28,7 @@ spec:
partition: 0
serviceName: {{ include "loki.writeFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.write.persistence.enableStatefulSetAutoDeletePVC) }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.write.persistence.enableStatefulSetAutoDeletePVC) (.Values.write.persistence.volumeClaimsEnabled) }}
{{/*
Data on the write nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
@ -155,6 +155,10 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- if not .Values.write.persistence.volumeClaimsEnabled }}
- name: data
{{- toYaml .Values.write.persistence.dataVolumeParameters | nindent 10 }}
{{- end}}
- name: config
{{- if .Values.loki.existingSecretForConfig }}
secret:
@ -177,6 +181,7 @@ spec:
{{- with .Values.write.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.write.persistence.volumeClaimsEnabled }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
@ -198,4 +203,5 @@ spec:
{{- with .Values.write.extraVolumeClaimTemplates }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}

@ -796,6 +796,11 @@ write:
# -- The default is to deploy all pods in parallel.
podManagementPolicy: "Parallel"
persistence:
# -- Enable volume claims in pod spec
volumeClaimsEnabled: true
# -- Parameters used for the `data` volume when volumeClaimEnabled if false
dataVolumeParameters:
emptyDir: {}
# -- Enable StatefulSetAutoDeletePVC feature
enableStatefulSetAutoDeletePVC: false
# -- Size of persistent disk
@ -1068,6 +1073,11 @@ backend:
# -- The default is to deploy all pods in parallel.
podManagementPolicy: "Parallel"
persistence:
# -- Enable volume claims in pod spec
volumeClaimsEnabled: true
# -- Parameters used for the `data` volume when volumeClaimEnabled if false
dataVolumeParameters:
emptyDir: {}
# -- Enable StatefulSetAutoDeletePVC feature
enableStatefulSetAutoDeletePVC: true
# -- Size of persistent disk

Loading…
Cancel
Save