Skip to content

Commit

Permalink
fix(helm/loki): Allow prefixing of rollout-group value and ingester name
Browse files Browse the repository at this point in the history
  • Loading branch information
boldfield committed Nov 22, 2024
1 parent dea5d78 commit fbf5d94
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 34 deletions.
4 changes: 4 additions & 0 deletions production/helm/loki/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.)

## 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
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion production/helm/loki/templates/ingester/_helpers-ingester.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,22 @@ expects a dict
*/}}
{{- define "loki.ingester.maxUnavailable" -}}
{{- ceil (mulf .replicas (divf (int .ctx.Values.ingester.zoneAwareReplication.maxUnavailablePct) 100)) -}}
{{- end -}}
{{- 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 -}}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
spec:
selector:
matchLabels:
rollout-group: ingester
rollout-group: {{ include "loki.prefixRolloutGroup" . }}ingester
{{- with .Values.ingester.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
- key: rollout-group
operator: NotIn
values:
- "ingester"
- '{{ include "loki.prefixRolloutGroup" . }}ingester'
{{- with .Values.ingester.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fbf5d94

Please sign in to comment.