From 3b4bd12db92f89dfa0a09edeb11fef031bd5b6af Mon Sep 17 00:00:00 2001 From: Mat Schaffer <115565899+matschaffer-roblox@users.noreply.github.com> Date: Thu, 5 Oct 2023 04:35:54 -0700 Subject: [PATCH] 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](https://github.com/grafana/loki/blob/45b127cfd62d8dedd46b189081d4259e6416ca24/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](https://github.com/grafana/loki/commit/d10549e3ece02120974929894ee333d07755d213) --------- Co-authored-by: J Stickler Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com> --- docs/sources/setup/install/helm/reference.md | 40 +++++++++++++++++++ production/helm/loki/CHANGELOG.md | 4 ++ production/helm/loki/Chart.yaml | 2 +- production/helm/loki/README.md | 2 +- .../backend/statefulset-backend.yaml | 8 +++- .../templates/write/statefulset-write.yaml | 8 +++- production/helm/loki/values.yaml | 10 +++++ 7 files changed, 70 insertions(+), 4 deletions(-) diff --git a/docs/sources/setup/install/helm/reference.md b/docs/sources/setup/install/helm/reference.md index 74be975672..7a6009d3d1 100644 --- a/docs/sources/setup/install/helm/reference.md +++ b/docs/sources/setup/install/helm/reference.md @@ -202,6 +202,17 @@ null
 {}
 
+ + + + backend.persistence.dataVolumeParameters + object + Parameters used for the `data` volume when volumeClaimEnabled if false +
+{
+  "emptyDir": {}
+}
+
@@ -238,6 +249,15 @@ null
 null
 
+ + + + backend.persistence.volumeClaimsEnabled + bool + Enable volume claims in pod spec +
+true
+
@@ -4546,6 +4566,17 @@ null
 {}
 
+ + + + write.persistence.dataVolumeParameters + object + Parameters used for the `data` volume when volumeClaimEnabled if false +
+{
+  "emptyDir": {}
+}
+
@@ -4582,6 +4613,15 @@ null
 null
 
+ + + + write.persistence.volumeClaimsEnabled + bool + Enable volume claims in pod spec +
+true
+
diff --git a/production/helm/loki/CHANGELOG.md b/production/helm/loki/CHANGELOG.md index 9b7f4c131e..389f52b9b8 100644 --- a/production/helm/loki/CHANGELOG.md +++ b/production/helm/loki/CHANGELOG.md @@ -13,6 +13,10 @@ Entries should include a reference to the pull request that introduced the chang [//]: # ( : 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 diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml index a7cff4bc7f..0ec8d47010 100644 --- a/production/helm/loki/Chart.yaml +++ b/production/helm/loki/Chart.yaml @@ -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 diff --git a/production/helm/loki/README.md b/production/helm/loki/README.md index 1c2956f09f..318ed08a82 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -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 diff --git a/production/helm/loki/templates/backend/statefulset-backend.yaml b/production/helm/loki/templates/backend/statefulset-backend.yaml index 7ea2ad5db0..26022c04ff 100644 --- a/production/helm/loki/templates/backend/statefulset-backend.yaml +++ b/production/helm/loki/templates/backend/statefulset-backend.yaml @@ -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 }} diff --git a/production/helm/loki/templates/write/statefulset-write.yaml b/production/helm/loki/templates/write/statefulset-write.yaml index 42644c49c0..79aed8ddd3 100644 --- a/production/helm/loki/templates/write/statefulset-write.yaml +++ b/production/helm/loki/templates/write/statefulset-write.yaml @@ -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 }} diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 24120c6fad..4ba3f3b41e 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -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