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 Dec 9, 2024
1 parent e784c93 commit cd3ffbd
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 33 deletions.
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 @@ -1893,6 +1893,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 cd3ffbd

Please sign in to comment.