From e0a3efc732eb9034f91dbd5ce64be4ab1fc0eb2b Mon Sep 17 00:00:00 2001 From: David Ham <64705+davidham@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:55:39 -0500 Subject: [PATCH 1/8] feat(index-gateway): Make updateStrategy configurable --- .../templates/index-gateway/statefulset-index-gateway.yaml | 3 +-- production/helm/loki/values.yaml | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml b/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml index 5797185ef0520..44f3aeca6f916 100644 --- a/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml +++ b/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml @@ -13,8 +13,7 @@ metadata: spec: replicas: {{ .Values.indexGateway.replicas }} updateStrategy: - rollingUpdate: - partition: 0 + type: {{ .Values.indexGateway.updateStrategy }} serviceName: {{ include "loki.indexGatewayFullname" . }}-headless revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.indexGateway.persistence.enableStatefulSetAutoDeletePVC) }} diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 3185f780ccd29..998d21cc93efe 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -2313,6 +2313,8 @@ indexGateway: # -- Set the optional grpc service protocol. Ex: "grpc", "http2" or "https" appProtocol: grpc: "" + # -- UpdateStrategy for the StatefulSet. One of 'OnDelete' or 'RollingUpdate'. + updateStrategy: RollingUpdate # -- Configuration for the compactor compactor: # -- Number of replicas for the compactor From 7dbabe04d69b6c28419afc0ae5396e15db4ae062 Mon Sep 17 00:00:00 2001 From: David Ham <64705+davidham@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:08:44 -0500 Subject: [PATCH 2/8] feat(ingester): Made statefulset updateStrategy configurable --- .../loki/templates/ingester/statefulset-ingester-zone-a.yaml | 2 +- .../loki/templates/ingester/statefulset-ingester-zone-b.yaml | 2 +- .../loki/templates/ingester/statefulset-ingester-zone-c.yaml | 2 +- .../helm/loki/templates/ingester/statefulset-ingester.yaml | 3 +-- production/helm/loki/values.yaml | 2 ++ 5 files changed, 6 insertions(+), 5 deletions(-) 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 13c7018e53e21..34f20352d0c56 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml @@ -41,7 +41,7 @@ spec: name: ingester-zone-a rollout-group: ingester updateStrategy: - type: OnDelete + type: {{ .Values.ingester.updateStrategy }} template: metadata: annotations: 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 3af81ae6477ef..f49850f766806 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml @@ -41,7 +41,7 @@ spec: name: ingester-zone-b rollout-group: ingester updateStrategy: - type: OnDelete + type: {{ .Values.ingester.updateStrategy }} template: metadata: annotations: 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 30393fa4d2cae..2958002be34a5 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml @@ -41,7 +41,7 @@ spec: name: ingester-zone-c rollout-group: ingester updateStrategy: - type: OnDelete + type: {{ .Values.ingester.updateStrategy }} template: metadata: annotations: diff --git a/production/helm/loki/templates/ingester/statefulset-ingester.yaml b/production/helm/loki/templates/ingester/statefulset-ingester.yaml index 9f3368a4b83e9..5f557f3a34753 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester.yaml @@ -18,8 +18,7 @@ spec: {{- end }} podManagementPolicy: Parallel updateStrategy: - rollingUpdate: - partition: 0 + type: {{ .Values.ingester.updateStrategy }} serviceName: {{ include "loki.ingesterFullname" . }}-headless revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }} diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 998d21cc93efe..cbb79aa0dbe30 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -1796,6 +1796,8 @@ ingester: readinessProbe: {} # -- liveness probe settings for ingester pods. If empty use `loki.livenessProbe` livenessProbe: {} + # -- UpdateStrategy for the ingester StatefulSets. One of 'RollingUpdate' or 'OnDelete'. + updateStrategy: RollingUpdate persistence: # -- Enable creating PVCs which is required when using boltdb-shipper enabled: false From 08842b5d8255ff8a9ffcd6f2ee7d1bd024110104 Mon Sep 17 00:00:00 2001 From: David Ham <64705+davidham@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:57:04 -0500 Subject: [PATCH 3/8] feat(tokengen): Updated role creation Changed the behavior so that if `.Values.rbac.namespaced` is enabled, it creates a Role instead of a ClusterRole for tokengen. --- .../helm/loki/templates/tokengen/clusterrole-tokengen.yaml | 4 ++-- .../templates/tokengen/clusterrolebinding-tokengen.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/production/helm/loki/templates/tokengen/clusterrole-tokengen.yaml b/production/helm/loki/templates/tokengen/clusterrole-tokengen.yaml index c67cec886471f..d357622cb2246 100644 --- a/production/helm/loki/templates/tokengen/clusterrole-tokengen.yaml +++ b/production/helm/loki/templates/tokengen/clusterrole-tokengen.yaml @@ -1,7 +1,7 @@ -{{ if and (and .Values.enterprise.tokengen.enabled .Values.enterprise.enabled) (not .Values.rbac.namespaced)}} +{{ if and .Values.enterprise.tokengen.enabled .Values.enterprise.enabled }} --- apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole +kind: {{ if not .Values.rbac.namespaced }}Cluster{{ end }}Role metadata: name: {{ template "enterprise-logs.tokengenFullname" . }} labels: diff --git a/production/helm/loki/templates/tokengen/clusterrolebinding-tokengen.yaml b/production/helm/loki/templates/tokengen/clusterrolebinding-tokengen.yaml index deb368f299369..fb21d8f64a87f 100644 --- a/production/helm/loki/templates/tokengen/clusterrolebinding-tokengen.yaml +++ b/production/helm/loki/templates/tokengen/clusterrolebinding-tokengen.yaml @@ -1,7 +1,7 @@ -{{ if and (and .Values.enterprise.tokengen.enabled .Values.enterprise.enabled) (not .Values.rbac.namespaced)}} +{{ if and .Values.enterprise.tokengen.enabled .Values.enterprise.enabled }} --- apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding +kind: {{ if not .Values.rbac.namespaced }}Cluster{{ end }}RoleBinding metadata: name: {{ template "enterprise-logs.tokengenFullname" . }} labels: @@ -16,7 +16,7 @@ metadata: "helm.sh/hook": post-install roleRef: apiGroup: rbac.authorization.k8s.io - kind: ClusterRole + kind: {{ if not .Values.rbac.namespaced }}Cluster{{ end }}Role name: {{ template "enterprise-logs.tokengenFullname" . }} subjects: - kind: ServiceAccount From 011a4a29b032d6c87da9567e6518db0a5e8ae817 Mon Sep 17 00:00:00 2001 From: David Ham <64705+davidham@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:04:27 -0500 Subject: [PATCH 4/8] docs: Corrected make target --- production/helm/loki/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/production/helm/loki/README.md b/production/helm/loki/README.md index 6f7566c606f9f..e152718c170ff 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -22,7 +22,7 @@ Find more information in the Loki Helm Chart [documentation](https://grafana.com ## Contributing and releasing -If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-doc` from the root of the repository to update the documentation and commit the changed files. +If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-docs` from the root of the repository to update the documentation and commit the changed files. #### Versioning From cf968033a67beec23c85b4ae7600310ebcf38d99 Mon Sep 17 00:00:00 2001 From: David Ham <64705+davidham@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:19:10 -0500 Subject: [PATCH 5/8] docs: Updated Helm docs --- docs/sources/setup/install/helm/reference.md | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/sources/setup/install/helm/reference.md b/docs/sources/setup/install/helm/reference.md index 43d246ec1fad1..c825bafc750b7 100644 --- a/docs/sources/setup/install/helm/reference.md +++ b/docs/sources/setup/install/helm/reference.md @@ -4628,7 +4628,8 @@ null "serviceAnnotations": {}, "serviceLabels": {}, "terminationGracePeriodSeconds": 300, - "tolerations": [] + "tolerations": [], + "updateStrategy": "RollingUpdate" } @@ -4912,6 +4913,15 @@ null
 []
 
+ + + + indexGateway.updateStrategy + string + UpdateStrategy for the StatefulSet. One of 'OnDelete' or 'RollingUpdate'. +
+"RollingUpdate"
+
@@ -5004,6 +5014,7 @@ null "whenUnsatisfiable": "ScheduleAnyway" } ], + "updateStrategy": "RollingUpdate", "zoneAwareReplication": { "enabled": true, "maxUnavailablePct": 33, @@ -5414,6 +5425,15 @@ false
 Defaults to allow skew no more than 1 node
 
+ + + + ingester.updateStrategy + string + UpdateStrategy for the ingester StatefulSets. One of 'RollingUpdate' or 'OnDelete'. +
+"RollingUpdate"
+
From f7223cae2ed7886a0813ccaa0f81e59c63dcbd6c Mon Sep 17 00:00:00 2001 From: David Ham <64705+davidham@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:32:33 -0500 Subject: [PATCH 6/8] fix: Change the template and not the output --- production/helm/loki/README.md | 2 +- production/helm/loki/README.md.gotmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/production/helm/loki/README.md b/production/helm/loki/README.md index e152718c170ff..6f7566c606f9f 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -22,7 +22,7 @@ Find more information in the Loki Helm Chart [documentation](https://grafana.com ## Contributing and releasing -If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-docs` from the root of the repository to update the documentation and commit the changed files. +If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-doc` from the root of the repository to update the documentation and commit the changed files. #### Versioning diff --git a/production/helm/loki/README.md.gotmpl b/production/helm/loki/README.md.gotmpl index f1af286656a24..72d55f3b44c9e 100644 --- a/production/helm/loki/README.md.gotmpl +++ b/production/helm/loki/README.md.gotmpl @@ -12,7 +12,7 @@ Find more information in the Loki Helm Chart [documentation](https://grafana.com ## Contributing and releasing -If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-doc` from the root of the repository to update the documentation and commit the changed files. +If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-docs` from the root of the repository to update the documentation and commit the changed files. #### Versioning From 03b08cdd84114bbaae4dfe51e5c076f6a840f4da Mon Sep 17 00:00:00 2001 From: David Ham <64705+davidham@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:24:23 -0500 Subject: [PATCH 7/8] feat: made updateStrategy a table for more flexibility --- docs/sources/setup/install/helm/reference.md | 34 ++++++++++++++++--- .../statefulset-index-gateway.yaml | 4 ++- .../ingester/statefulset-ingester-zone-a.yaml | 4 ++- .../ingester/statefulset-ingester-zone-b.yaml | 4 ++- .../ingester/statefulset-ingester-zone-c.yaml | 4 ++- .../ingester/statefulset-ingester.yaml | 4 ++- production/helm/loki/values.yaml | 18 +++++++--- 7 files changed, 59 insertions(+), 13 deletions(-) diff --git a/docs/sources/setup/install/helm/reference.md b/docs/sources/setup/install/helm/reference.md index c825bafc750b7..f5c4ed1122738 100644 --- a/docs/sources/setup/install/helm/reference.md +++ b/docs/sources/setup/install/helm/reference.md @@ -4629,7 +4629,9 @@ null "serviceLabels": {}, "terminationGracePeriodSeconds": 300, "tolerations": [], - "updateStrategy": "RollingUpdate" + "updateStrategy": { + "type": "RollingUpdate" + } } @@ -4917,8 +4919,19 @@ null indexGateway.updateStrategy + object + UpdateStrategy for the indexGateway StatefulSet. +
+{
+  "type": "RollingUpdate"
+}
+
+ + + + indexGateway.updateStrategy.type string - UpdateStrategy for the StatefulSet. One of 'OnDelete' or 'RollingUpdate'. + One of 'OnDelete' or 'RollingUpdate'
 "RollingUpdate"
 
@@ -5014,7 +5027,9 @@ null "whenUnsatisfiable": "ScheduleAnyway" } ], - "updateStrategy": "RollingUpdate", + "updateStrategy": { + "type": "RollingUpdate" + }, "zoneAwareReplication": { "enabled": true, "maxUnavailablePct": 33, @@ -5429,8 +5444,19 @@ Defaults to allow skew no more than 1 node ingester.updateStrategy + object + UpdateStrategy for the ingester StatefulSets. +
+{
+  "type": "RollingUpdate"
+}
+
+ + + + ingester.updateStrategy.type string - UpdateStrategy for the ingester StatefulSets. One of 'RollingUpdate' or 'OnDelete'. + One of 'OnDelete' or 'RollingUpdate'
 "RollingUpdate"
 
diff --git a/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml b/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml index 44f3aeca6f916..0eb7cf3a911e4 100644 --- a/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml +++ b/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml @@ -12,8 +12,10 @@ metadata: {{- end }} spec: replicas: {{ .Values.indexGateway.replicas }} +{{- with .Values.indexGateway.updateStrategy }} updateStrategy: - type: {{ .Values.indexGateway.updateStrategy }} + {{- tpl (. | toYaml) $ | nindent 4 }} +{{- end }} serviceName: {{ include "loki.indexGatewayFullname" . }}-headless revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.indexGateway.persistence.enableStatefulSetAutoDeletePVC) }} 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 34f20352d0c56..11d360f24f270 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml @@ -40,8 +40,10 @@ spec: {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} name: ingester-zone-a rollout-group: ingester +{{- with .Values.ingester.updateStrategy }} updateStrategy: - type: {{ .Values.ingester.updateStrategy }} + {{- tpl (. | toYaml) $ | nindent 4 }} +{{- end }} template: metadata: annotations: 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 f49850f766806..8a46273fea049 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml @@ -40,8 +40,10 @@ spec: {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} name: ingester-zone-b rollout-group: ingester +{{- with .Values.ingester.updateStrategy }} updateStrategy: - type: {{ .Values.ingester.updateStrategy }} + {{- tpl (. | toYaml) $ | nindent 4 }} +{{- end }} template: metadata: annotations: 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 2958002be34a5..55c25396c956e 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml @@ -40,8 +40,10 @@ spec: {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} name: ingester-zone-c rollout-group: ingester +{{- with .Values.ingester.updateStrategy }} updateStrategy: - type: {{ .Values.ingester.updateStrategy }} + {{- tpl (. | toYaml) $ | nindent 4 }} +{{- end }} template: metadata: annotations: diff --git a/production/helm/loki/templates/ingester/statefulset-ingester.yaml b/production/helm/loki/templates/ingester/statefulset-ingester.yaml index 5f557f3a34753..adeeb3b5e6e9e 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester.yaml @@ -17,8 +17,10 @@ spec: replicas: {{ .Values.ingester.replicas }} {{- end }} podManagementPolicy: Parallel +{{- with .Values.ingester.updateStrategy }} updateStrategy: - type: {{ .Values.ingester.updateStrategy }} + {{- tpl (. | toYaml) $ | nindent 4 }} +{{- end }} serviceName: {{ include "loki.ingesterFullname" . }}-headless revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }} diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index cbb79aa0dbe30..7870f53393c87 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -1796,8 +1796,13 @@ ingester: readinessProbe: {} # -- liveness probe settings for ingester pods. If empty use `loki.livenessProbe` livenessProbe: {} - # -- UpdateStrategy for the ingester StatefulSets. One of 'RollingUpdate' or 'OnDelete'. - updateStrategy: RollingUpdate + # -- UpdateStrategy for the ingester StatefulSets. + updateStrategy: + # -- One of 'OnDelete' or 'RollingUpdate' + type: RollingUpdate + # -- Optional for updateStrategy.type=RollingUpdate. See [Partitioned rolling updates](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions) in the StatefulSet docs for details. + # rollingUpdate: + # partition: 0 persistence: # -- Enable creating PVCs which is required when using boltdb-shipper enabled: false @@ -2315,8 +2320,13 @@ indexGateway: # -- Set the optional grpc service protocol. Ex: "grpc", "http2" or "https" appProtocol: grpc: "" - # -- UpdateStrategy for the StatefulSet. One of 'OnDelete' or 'RollingUpdate'. - updateStrategy: RollingUpdate + # -- UpdateStrategy for the indexGateway StatefulSet. + updateStrategy: + # -- One of 'OnDelete' or 'RollingUpdate' + type: RollingUpdate + # -- Optional for updateStrategy.type=RollingUpdate. See [Partitioned rolling updates](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions) in the StatefulSet docs for details. + # rollingUpdate: + # partition: 0 # -- Configuration for the compactor compactor: # -- Number of replicas for the compactor From cf42730c4679a044714a640c32e7ff8cb343ae16 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Thu, 10 Oct 2024 07:23:27 -0300 Subject: [PATCH 8/8] update README.md file --- production/helm/loki/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/production/helm/loki/README.md b/production/helm/loki/README.md index 6f7566c606f9f..e152718c170ff 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -22,7 +22,7 @@ Find more information in the Loki Helm Chart [documentation](https://grafana.com ## Contributing and releasing -If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-doc` from the root of the repository to update the documentation and commit the changed files. +If you made any changes to the [Chart.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/Chart.yaml) or [values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml) run `make helm-docs` from the root of the repository to update the documentation and commit the changed files. #### Versioning