From fe223a21e5b4cba648bc8a4393200a2ef3e0599c Mon Sep 17 00:00:00 2001 From: Anton Lindholm Date: Thu, 21 Sep 2023 16:16:49 +0300 Subject: [PATCH] helm: improve gitops compatibility (#10452) **What this PR does / why we need it**: In its current form, this helm chart is annoying to deploy using GitOps tools like fluxcd/argocd. This is due to missing fields that get added automatically once the objects are applied in the cluster. A workaround is to just add exceptions for these fields in the gitops tool, but I think this is a more robust solution. Screenshot from ArgoCD app diff: ![image](https://github.com/grafana/loki/assets/11833599/21644b4c-bffd-4052-8a4c-bf602e88a878) **Which issue(s) this PR fixes**: **Special notes for your reviewer**: **Checklist** - [x] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [ ] Documentation added - [ ] Tests updated - [ ] `CHANGELOG.md` updated - [ ] If the change is worth mentioning in the release notes, add `add-to-release-notes` label - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/setup/upgrade/_index.md` - [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: Michel Hollands <42814411+MichelHollands@users.noreply.github.com> --- production/helm/loki/CHANGELOG.md | 5 ++++- production/helm/loki/Chart.yaml | 2 +- production/helm/loki/README.md | 2 +- .../helm/loki/templates/backend/statefulset-backend.yaml | 4 +++- .../helm/loki/templates/monitoring/servicemonitor.yaml | 4 +++- production/helm/loki/templates/read/statefulset-read.yaml | 4 +++- production/helm/loki/templates/write/statefulset-write.yaml | 4 +++- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/production/helm/loki/CHANGELOG.md b/production/helm/loki/CHANGELOG.md index e207293c9e2b5..c00f04b837085 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.22.1 + +- ENHANCEMENT #10452 Improve gitops compatibility + ## 5.22.0 - [CHANGE] Changed version of Loki to 2.9.1 @@ -27,7 +31,6 @@ Entries should include a reference to the pull request that introduced the chang - [CHANGE] Changed version of Grafana Enterprise Logs to v1.8.0 - ## 5.19.0 - [FEATURE] Add optional sidecard to load rules from ConfigMaps and Secrets. diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml index c8983eee13055..58c5a3ccc020b 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.22.0 +version: 5.22.1 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 93937159f6440..7103f5b6ff81c 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -1,6 +1,6 @@ # loki -![Version: 5.22.0](https://img.shields.io/badge/Version-5.22.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.22.1](https://img.shields.io/badge/Version-5.22.1-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 7e7cf6105592d..1ec867d5f503d 100644 --- a/production/helm/loki/templates/backend/statefulset-backend.yaml +++ b/production/helm/loki/templates/backend/statefulset-backend.yaml @@ -252,7 +252,9 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumeClaimTemplates: - - metadata: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: name: data spec: accessModes: diff --git a/production/helm/loki/templates/monitoring/servicemonitor.yaml b/production/helm/loki/templates/monitoring/servicemonitor.yaml index 67b03c6feee55..4bc56a84740f5 100644 --- a/production/helm/loki/templates/monitoring/servicemonitor.yaml +++ b/production/helm/loki/templates/monitoring/servicemonitor.yaml @@ -38,9 +38,11 @@ spec: {{- end }} relabelings: - sourceLabels: [job] + action: replace replacement: "{{ $.Release.Namespace }}/$1" targetLabel: job - - replacement: "{{ include "loki.clusterLabel" $ }}" + - action: replace + replacement: "{{ include "loki.clusterLabel" $ }}" targetLabel: cluster {{- with .relabelings }} {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/templates/read/statefulset-read.yaml b/production/helm/loki/templates/read/statefulset-read.yaml index 37c35df7767d9..a9213e7f98794 100644 --- a/production/helm/loki/templates/read/statefulset-read.yaml +++ b/production/helm/loki/templates/read/statefulset-read.yaml @@ -162,7 +162,9 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumeClaimTemplates: - - metadata: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: name: data spec: accessModes: diff --git a/production/helm/loki/templates/write/statefulset-write.yaml b/production/helm/loki/templates/write/statefulset-write.yaml index a10ba2d883a2c..3c1d84fc3b611 100644 --- a/production/helm/loki/templates/write/statefulset-write.yaml +++ b/production/helm/loki/templates/write/statefulset-write.yaml @@ -177,7 +177,9 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumeClaimTemplates: - - metadata: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: name: data spec: accessModes: