From ef1df0e66fc8e2fe9327a66aea31279ca5c7307a Mon Sep 17 00:00:00 2001 From: Andre Ziviani <7469258+AndreZiviani@users.noreply.github.com> Date: Mon, 2 Sep 2024 02:56:26 -0300 Subject: [PATCH] feat(helm): Add persistence option to memcached on Helm chart (#13619) Add an option to configure persistence on memcached, very useful with extstore option. More info on Grafana Blog post (https://grafana.com/blog/2023/08/23/how-we-scaled-grafana-cloud-logs-memcached-cluster-to-50tb-and-improved-reliability/), based mostly on `loki-distributed` Helm chart. --- docs/sources/setup/install/helm/reference.md | 100 ++++++++++++++++++ production/helm/loki/CHANGELOG.md | 5 +- production/helm/loki/Chart.yaml | 2 +- production/helm/loki/README.md | 2 +- .../memcached/_memcached-statefulset.tpl | 23 +++- production/helm/loki/values.yaml | 28 +++++ 6 files changed, 155 insertions(+), 5 deletions(-) diff --git a/docs/sources/setup/install/helm/reference.md b/docs/sources/setup/install/helm/reference.md index b3c2bba85351..b616845c7d13 100644 --- a/docs/sources/setup/install/helm/reference.md +++ b/docs/sources/setup/install/helm/reference.md @@ -1623,6 +1623,56 @@ true
 5
 
+ + + + chunksCache.persistence + object + Persistence settings for the chunks-cache +
+{
+  "enabled": false,
+  "mountPath": "/data",
+  "storageClass": null,
+  "storageSize": "10G"
+}
+
+ + + + chunksCache.persistence.enabled + bool + Enable creating PVCs for the chunks-cache +
+false
+
+ + + + chunksCache.persistence.mountPath + string + Volume mount path +
+"/data"
+
+ + + + chunksCache.persistence.storageClass + string + Storage class to be used. If defined, storageClassName: . If set to "-", storageClassName: "", which disables dynamic provisioning. If empty or set to null, no storageClassName spec is set, choosing the default provisioner (gp2 on AWS, standard on GKE, AWS, and OpenStack). +
+null
+
+ + + + chunksCache.persistence.storageSize + string + Size of persistent disk +
+"10G"
+
@@ -9035,6 +9085,56 @@ true
 {}
 
+ + + + resultsCache.persistence + object + Persistence settings for the results-cache +
+{
+  "enabled": false,
+  "mountPath": "/data",
+  "storageClass": null,
+  "storageSize": "10G"
+}
+
+ + + + resultsCache.persistence.enabled + bool + Enable creating PVCs for the results-cache +
+false
+
+ + + + resultsCache.persistence.mountPath + string + Volume mount path +
+"/data"
+
+ + + + resultsCache.persistence.storageClass + string + Storage class to be used. If defined, storageClassName: . If set to "-", storageClassName: "", which disables dynamic provisioning. If empty or set to null, no storageClassName spec is set, choosing the default provisioner (gp2 on AWS, standard on GKE, AWS, and OpenStack). +
+null
+
+ + + + resultsCache.persistence.storageSize + string + Size of persistent disk +
+"10G"
+
diff --git a/production/helm/loki/CHANGELOG.md b/production/helm/loki/CHANGELOG.md index ba47de6f8442..4efe3289a67e 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.) +## 6.11.0 + +- [FEATURE] Add support for configuring persistence for memcached. + ## 6.10.2 - [CHANGE] Bumped version of `nginxinc/nginx-unprivileged` to 1.27-alpine; this remediates several CVE @@ -27,7 +31,6 @@ Entries should include a reference to the pull request that introduced the chang - [CHANGE] Changed version of Grafana Loki to 3.1.1 - [ENHANCEMENT] Added ability to disable AWS S3 dualstack endpoint usage. - ## 6.9.0 - [BUGFIX] Fixed how we set imagePullSecrets for the memcached and provisioner. diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml index 9c6acfe2bdd2..c6fcd38c5c54 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 and Grafana Enterprise Logs supporting both simple, scalable and distributed modes. type: application appVersion: 3.1.1 -version: 6.10.2 +version: 6.11.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 59208a9c6413..c29dbfe95c4f 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -1,6 +1,6 @@ # loki -![Version: 6.10.2](https://img.shields.io/badge/Version-6.10.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.1.1](https://img.shields.io/badge/AppVersion-3.1.1-informational?style=flat-square) +![Version: 6.11.0](https://img.shields.io/badge/Version-6.11.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.1.1](https://img.shields.io/badge/AppVersion-3.1.1-informational?style=flat-square) Helm chart for Grafana Loki and Grafana Enterprise Logs supporting both simple, scalable and distributed modes. diff --git a/production/helm/loki/templates/memcached/_memcached-statefulset.tpl b/production/helm/loki/templates/memcached/_memcached-statefulset.tpl index 8e2479af8a05..ce490ee6cd71 100644 --- a/production/helm/loki/templates/memcached/_memcached-statefulset.tpl +++ b/production/helm/loki/templates/memcached/_memcached-statefulset.tpl @@ -104,7 +104,7 @@ spec: name: client args: - -m {{ .allocatedMemory }} - - --extended=modern,track_sizes{{ with .extraExtendedOptions }},{{ . }}{{ end }} + - --extended=modern,track_sizes{{ if .persistence.enabled }},ext_path={{ .persistence.mountPath }}/file:{{ .persistence.storageSize }}{{ end }}{{ with .extraExtendedOptions }},{{ . }}{{ end }} - -I {{ .maxItemMemory }}m - -c {{ .connectionLimit }} - -v @@ -122,10 +122,16 @@ spec: {{- end }} securityContext: {{- toYaml $.ctx.Values.memcached.containerSecurityContext | nindent 12 }} - {{- if .extraVolumeMounts }} + {{- if or .persistence.enabled .extraVolumeMounts }} volumeMounts: + {{- if .persistence.enabled }} + - name: data + mountPath: {{ .persistence.mountPath }} + {{- end }} + {{- if .extraVolumeMounts }} {{- toYaml .extraVolumeMounts | nindent 12 }} {{- end }} + {{- end }} {{- if $.ctx.Values.memcachedExporter.enabled }} - name: exporter @@ -151,6 +157,19 @@ spec: {{- toYaml .extraVolumeMounts | nindent 12 }} {{- end }} {{- end }} + {{- if .persistence.enabled }} + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: [ "ReadWriteOnce" ] + {{- with .persistence.storageClass }} + storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} + {{- end }} + resources: + requests: + storage: {{ .persistence.storageSize | quote }} + {{- end }} {{- end -}} {{- end -}} {{- end -}} diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index ef0c506f585a..dd6df92348ca 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -2967,6 +2967,20 @@ resultsCache: service: annotations: {} labels: {} + # -- Persistence settings for the results-cache + persistence: + # -- Enable creating PVCs for the results-cache + enabled: false + # -- Size of persistent disk + storageSize: 10G + # -- Storage class to be used. + # If defined, storageClassName: . + # If set to "-", storageClassName: "", which disables dynamic provisioning. + # If empty or set to null, no storageClassName spec is + # set, choosing the default provisioner (gp2 on AWS, standard on GKE, AWS, and OpenStack). + storageClass: null + # -- Volume mount path + mountPath: /data chunksCache: # -- Specifies whether memcached based chunks-cache should be enabled enabled: true @@ -3055,6 +3069,20 @@ chunksCache: service: annotations: {} labels: {} + # -- Persistence settings for the chunks-cache + persistence: + # -- Enable creating PVCs for the chunks-cache + enabled: false + # -- Size of persistent disk + storageSize: 10G + # -- Storage class to be used. + # If defined, storageClassName: . + # If set to "-", storageClassName: "", which disables dynamic provisioning. + # If empty or set to null, no storageClassName spec is + # set, choosing the default provisioner (gp2 on AWS, standard on GKE, AWS, and OpenStack). + storageClass: null + # -- Volume mount path + mountPath: /data ###################################################################################################################### # # Subchart configurations