From fbf5d948033d73da73a3e804b3e7b1b3a9e87176 Mon Sep 17 00:00:00 2001 From: Brian Oldfield Date: Thu, 21 Nov 2024 12:05:47 -0800 Subject: [PATCH] fix(helm/loki): Allow prefixing of rollout-group value and ingester name --- production/helm/loki/CHANGELOG.md | 4 ++++ production/helm/loki/Chart.yaml | 2 +- .../templates/ingester/_helpers-ingester.tpl | 20 ++++++++++++++++++- .../poddisruptionbudget-ingester-rollout.yaml | 2 +- .../poddisruptionbudget-ingester.yaml | 2 +- .../service-ingester-zone-a-headless.yaml | 4 ++-- .../service-ingester-zone-b-headless.yaml | 4 ++-- .../service-ingester-zone-c-headless.yaml | 4 ++-- .../ingester/statefulset-ingester-zone-a.yaml | 16 +++++++-------- .../ingester/statefulset-ingester-zone-b.yaml | 16 +++++++-------- .../ingester/statefulset-ingester-zone-c.yaml | 16 +++++++-------- production/helm/loki/values.yaml | 6 ++++++ 12 files changed, 62 insertions(+), 34 deletions(-) diff --git a/production/helm/loki/CHANGELOG.md b/production/helm/loki/CHANGELOG.md index b1273e533c1e..9e9878f6c8c4 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.20.1 +- [BUGFIX] Optionally allow prefixing in Ingester rollout-group labels with user defined string +- [BUGFIX] Optionally allow prefixing Ingester StatefulSet name to avoid __ with rollout-operator + ## 6.20.0 - [CHANGE] Changed version of Grafana Loki to 3.3.0 diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml index 7e09fdbeee3b..4d8ee4d57d18 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.3.0 -version: 6.21.0 +version: 6.21.1 home: https://grafana.github.io/helm-charts sources: - https://github.com/grafana/loki diff --git a/production/helm/loki/templates/ingester/_helpers-ingester.tpl b/production/helm/loki/templates/ingester/_helpers-ingester.tpl index 418d4094d5ff..70728a085ee2 100644 --- a/production/helm/loki/templates/ingester/_helpers-ingester.tpl +++ b/production/helm/loki/templates/ingester/_helpers-ingester.tpl @@ -71,4 +71,22 @@ expects a dict */}} {{- define "loki.ingester.maxUnavailable" -}} {{- ceil (mulf .replicas (divf (int .ctx.Values.ingester.zoneAwareReplication.maxUnavailablePct) 100)) -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Return rollout-group prefix if it is set +*/}} +{{- define "loki.prefixRolloutGroup" -}} +{{- if .Values.ingester.rolloutGroupPrefix -}} +{{- .Values.ingester.rolloutGroupPrefix -}}- +{{- end -}} +{{- end -}} + +{{/* +Return ingester name prefix if required +*/}} +{{- define "loki.prefixIngesterName" -}} +{{- if .Values.ingester.addIngesterNamePrefix -}} +loki- +{{- end -}} +{{- end -}} diff --git a/production/helm/loki/templates/ingester/poddisruptionbudget-ingester-rollout.yaml b/production/helm/loki/templates/ingester/poddisruptionbudget-ingester-rollout.yaml index 000ab8569ad0..4c1b133050a7 100644 --- a/production/helm/loki/templates/ingester/poddisruptionbudget-ingester-rollout.yaml +++ b/production/helm/loki/templates/ingester/poddisruptionbudget-ingester-rollout.yaml @@ -13,7 +13,7 @@ metadata: spec: selector: matchLabels: - rollout-group: ingester + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- with .Values.ingester.maxUnavailable }} maxUnavailable: {{ . }} {{- end }} diff --git a/production/helm/loki/templates/ingester/poddisruptionbudget-ingester.yaml b/production/helm/loki/templates/ingester/poddisruptionbudget-ingester.yaml index 1142c010218a..f5c4838b677e 100644 --- a/production/helm/loki/templates/ingester/poddisruptionbudget-ingester.yaml +++ b/production/helm/loki/templates/ingester/poddisruptionbudget-ingester.yaml @@ -19,7 +19,7 @@ spec: - key: rollout-group operator: NotIn values: - - "ingester" + - '{{ include "loki.prefixRolloutGroup" . }}ingester' {{- with .Values.ingester.maxUnavailable }} maxUnavailable: {{ . }} {{- end }} diff --git a/production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml b/production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml index 03add3b286fc..380ed09e5455 100644 --- a/production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml +++ b/production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml @@ -33,6 +33,6 @@ spec: {{- end }} selector: {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} - name: ingester-zone-a - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-a + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- end -}} diff --git a/production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml b/production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml index 607221922a66..00d851f5c4ff 100644 --- a/production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml +++ b/production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml @@ -33,6 +33,6 @@ spec: {{- end }} selector: {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} - name: ingester-zone-b - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-b + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- end -}} diff --git a/production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml b/production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml index 554144746ae0..0bacdbc27f97 100644 --- a/production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml +++ b/production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml @@ -33,6 +33,6 @@ spec: {{- end }} selector: {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} - name: ingester-zone-c - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-c + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- end -}} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml b/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml index a7316612b5ab..2284a0ba3761 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml @@ -9,8 +9,8 @@ metadata: labels: {{- include "loki.ingesterLabels" . | nindent 4 }} app.kubernetes.io/part-of: memberlist - rollout-group: ingester - name: ingester-zone-a + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-a + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester annotations: rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}" {{- with .Values.loki.annotations }} @@ -38,8 +38,8 @@ spec: selector: matchLabels: {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} - name: ingester-zone-a - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-a + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- with .Values.ingester.updateStrategy }} updateStrategy: {{- tpl (. | toYaml) $ | nindent 4 }} @@ -60,8 +60,8 @@ spec: labels: {{- include "loki.ingesterSelectorLabels" . | nindent 8 }} app.kubernetes.io/part-of: memberlist - name: ingester-zone-a - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-a + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- with .Values.loki.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} @@ -164,11 +164,11 @@ spec: - key: rollout-group operator: In values: - - ingester + - {{ include "loki.prefixRolloutGroup" . }}ingester - key: name operator: NotIn values: - - ingester-zone-a + - {{ include "loki.prefixIngesterName" . }}ingester-zone-a topologyKey: kubernetes.io/hostname {{- with .Values.ingester.zoneAwareReplication.zoneA.extraAffinity }} {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml b/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml index 75124542a06d..da55790500cc 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml @@ -9,8 +9,8 @@ metadata: labels: {{- include "loki.ingesterLabels" . | nindent 4 }} app.kubernetes.io/part-of: memberlist - rollout-group: ingester - name: ingester-zone-b + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-b + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester annotations: rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}" {{- with .Values.loki.annotations }} @@ -38,8 +38,8 @@ spec: selector: matchLabels: {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} - name: ingester-zone-b - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-b + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- with .Values.ingester.updateStrategy }} updateStrategy: {{- tpl (. | toYaml) $ | nindent 4 }} @@ -60,8 +60,8 @@ spec: labels: {{- include "loki.ingesterSelectorLabels" . | nindent 8 }} app.kubernetes.io/part-of: memberlist - name: ingester-zone-b - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-b + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- with .Values.loki.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} @@ -164,11 +164,11 @@ spec: - key: rollout-group operator: In values: - - ingester + - {{ include "loki.prefixRolloutGroup" . }}ingester - key: name operator: NotIn values: - - ingester-zone-b + - {{ include "loki.prefixIngesterName" . }}ingester-zone-b topologyKey: kubernetes.io/hostname {{- with .Values.ingester.zoneAwareReplication.zoneB.extraAffinity }} {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml b/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml index 657d6a51d46a..718eae78a3e1 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml @@ -9,8 +9,8 @@ metadata: labels: {{- include "loki.ingesterLabels" . | nindent 4 }} app.kubernetes.io/part-of: memberlist - rollout-group: ingester - name: ingester-zone-c + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-c + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester annotations: rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}" {{- with .Values.loki.annotations }} @@ -38,8 +38,8 @@ spec: selector: matchLabels: {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} - name: ingester-zone-c - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-c + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- with .Values.ingester.updateStrategy }} updateStrategy: {{- tpl (. | toYaml) $ | nindent 4 }} @@ -60,8 +60,8 @@ spec: labels: {{- include "loki.ingesterSelectorLabels" . | nindent 8 }} app.kubernetes.io/part-of: memberlist - name: ingester-zone-c - rollout-group: ingester + name: {{ include "loki.prefixIngesterName" . }}ingester-zone-c + rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester {{- with .Values.loki.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} @@ -164,11 +164,11 @@ spec: - key: rollout-group operator: In values: - - ingester + - {{ include "loki.prefixIngesterName" . }}ingester - key: name operator: NotIn values: - - ingester-zone-c + - {{ include "loki.prefixIngesterName" . }}ingester-zone-c topologyKey: kubernetes.io/hostname {{- with .Values.ingester.zoneAwareReplication.zoneC.extraAffinity }} {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 78961a724300..1a842dbb5d1f 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -1891,6 +1891,12 @@ ingester: excludeDefaultZone: false readPath: false writePath: false + + # optionally allow adding arbitrary prefix to the ingester rollout-group label + rolloutGroupPrefix: null + # optionally allow adding 'loki-' prefix to ingester name label + addIngesterNamePrefix: false + # -- Configuration for the distributor distributor: # -- Number of replicas for the distributor