From d0751071a4db971788c93f89a1add97887cb2e6d Mon Sep 17 00:00:00 2001 From: mericks Date: Wed, 13 Nov 2024 08:30:05 -0800 Subject: [PATCH] feat: expose topologySpreadConstraints for distributed deployment (#14853) --- docs/sources/setup/install/helm/reference.md | 80 +++++++++++++++++-- production/helm/loki/CHANGELOG.md | 2 + .../compactor/statefulset-compactor.yaml | 2 +- .../distributor/deployment-distributor.yaml | 6 ++ .../deployment-gateway-enterprise.yaml | 8 +- .../statefulset-index-gateway.yaml | 4 + .../ingester/statefulset-ingester-zone-a.yaml | 2 +- .../ingester/statefulset-ingester-zone-b.yaml | 2 +- .../ingester/statefulset-ingester-zone-c.yaml | 2 +- .../ingester/statefulset-ingester.yaml | 2 +- .../statefulset-pattern-ingester.yaml | 4 + .../templates/querier/deployment-querier.yaml | 2 +- .../deployment-query-frontend.yaml | 6 ++ .../deployment-query-scheduler.yaml | 6 ++ .../templates/ruler/statefulset-ruler.yaml | 6 ++ production/helm/loki/values.yaml | 14 ++++ 16 files changed, 136 insertions(+), 12 deletions(-) diff --git a/docs/sources/setup/install/helm/reference.md b/docs/sources/setup/install/helm/reference.md index 5ab32a5fedd5b..4076e156b2c95 100644 --- a/docs/sources/setup/install/helm/reference.md +++ b/docs/sources/setup/install/helm/reference.md @@ -2695,7 +2695,8 @@ null "serviceAnnotations": {}, "serviceLabels": {}, "terminationGracePeriodSeconds": 30, - "tolerations": [] + "tolerations": [], + "topologySpreadConstraints": [] } @@ -3015,6 +3016,15 @@ null
 []
 
+ + + + distributor.topologySpreadConstraints + list + Topology Spread Constraints for distributor pods +
+[]
+
@@ -3658,6 +3668,7 @@ false }, "terminationGracePeriodSeconds": 60, "tolerations": [], + "topologySpreadConstraints": [], "useDefaultProxyURLs": true } @@ -3858,6 +3869,15 @@ false
 []
 
+ + + + enterpriseGateway.topologySpreadConstraints + list + Topology Spread Constraints for enterprise-gateway pods +
+[]
+
@@ -4658,6 +4678,7 @@ null "serviceLabels": {}, "terminationGracePeriodSeconds": 300, "tolerations": [], + "topologySpreadConstraints": [], "updateStrategy": { "type": "RollingUpdate" } @@ -4944,6 +4965,15 @@ null
 []
 
+ + + + indexGateway.topologySpreadConstraints + list + Topology Spread Constraints for index-gateway pods +
+[]
+
@@ -7686,7 +7716,8 @@ false "serviceAnnotations": {}, "serviceLabels": {}, "terminationGracePeriodSeconds": 30, - "tolerations": [] + "tolerations": [], + "topologySpreadConstraints": [] } @@ -8015,6 +8046,15 @@ null
 []
 
+ + + + patternIngester.topologySpreadConstraints + list + Topology Spread Constraints for pattern ingester pods +
+[]
+
@@ -8541,7 +8581,8 @@ Defaults to allow skew no more then 1 node "serviceAnnotations": {}, "serviceLabels": {}, "terminationGracePeriodSeconds": 30, - "tolerations": [] + "tolerations": [], + "topologySpreadConstraints": [] } @@ -8852,6 +8893,15 @@ null
 []
 
+ + + + queryFrontend.topologySpreadConstraints + list + Topology Spread Constraints for query-frontend pods +
+[]
+
@@ -8899,7 +8949,8 @@ null "serviceAnnotations": {}, "serviceLabels": {}, "terminationGracePeriodSeconds": 30, - "tolerations": [] + "tolerations": [], + "topologySpreadConstraints": [] } @@ -9111,6 +9162,15 @@ null
 []
 
+ + + + queryScheduler.topologySpreadConstraints + list + Topology Spread Constraints for query-scheduler pods +
+[]
+
@@ -10008,7 +10068,8 @@ null "serviceAnnotations": {}, "serviceLabels": {}, "terminationGracePeriodSeconds": 300, - "tolerations": [] + "tolerations": [], + "topologySpreadConstraints": [] } @@ -10301,6 +10362,15 @@ null
 []
 
+ + + + ruler.topologySpreadConstraints + list + Topology Spread Constraints for ruler pods +
+[]
+
diff --git a/production/helm/loki/CHANGELOG.md b/production/helm/loki/CHANGELOG.md index 77e1971531421..5f477f978c2ec 100644 --- a/production/helm/loki/CHANGELOG.md +++ b/production/helm/loki/CHANGELOG.md @@ -13,6 +13,8 @@ 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.) +- [ENHANCEMENT] Expose Topology Spread Constraints in Helm chart templates and default values. + ## 6.19.0 ## 6.18.0 diff --git a/production/helm/loki/templates/compactor/statefulset-compactor.yaml b/production/helm/loki/templates/compactor/statefulset-compactor.yaml index 944ac425bf5ad..62944882a79ee 100644 --- a/production/helm/loki/templates/compactor/statefulset-compactor.yaml +++ b/production/helm/loki/templates/compactor/statefulset-compactor.yaml @@ -48,7 +48,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} {{- with .Values.compactor.topologySpreadConstraints }} topologySpreadConstraints: {{- tpl . $ | nindent 8 }} diff --git a/production/helm/loki/templates/distributor/deployment-distributor.yaml b/production/helm/loki/templates/distributor/deployment-distributor.yaml index be66bfc6b5240..556a0534f75cb 100644 --- a/production/helm/loki/templates/distributor/deployment-distributor.yaml +++ b/production/helm/loki/templates/distributor/deployment-distributor.yaml @@ -44,6 +44,12 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.distributor.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} serviceAccountName: {{ include "loki.serviceAccountName" . }} {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml b/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml index d75fd5fe65492..eb089a1a60cfd 100644 --- a/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml +++ b/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml @@ -38,6 +38,12 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.enterpriseGateway.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} serviceAccountName: {{ template "loki.serviceAccountName" . }} {{- if .Values.enterpriseGateway.priorityClassName }} priorityClassName: {{ .Values.enterpriseGateway.priorityClassName }} @@ -143,4 +149,4 @@ spec: {{- if .Values.enterpriseGateway.extraVolumes }} {{ toYaml .Values.enterpriseGateway.extraVolumes | nindent 8 }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} 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 d417c978140f7..8688a55bcb8f9 100644 --- a/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml +++ b/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml @@ -132,6 +132,10 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.indexGateway.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.indexGateway.tolerations }} tolerations: {{- toYaml . | nindent 8 }} 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 e4c35c7dd84c9..a7316612b5abe 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml @@ -69,7 +69,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} {{- with .Values.ingester.topologySpreadConstraints }} topologySpreadConstraints: {{- 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 db499cae8d583..75124542a06d8 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml @@ -69,7 +69,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} {{- with .Values.ingester.topologySpreadConstraints }} topologySpreadConstraints: {{- 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 994b460b9a15f..657d6a51d46a6 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml @@ -69,7 +69,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} {{- with .Values.ingester.topologySpreadConstraints }} topologySpreadConstraints: {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester.yaml b/production/helm/loki/templates/ingester/statefulset-ingester.yaml index f66145c1720fd..217196a5f1e86 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester.yaml @@ -55,7 +55,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} {{- with .Values.ingester.topologySpreadConstraints }} topologySpreadConstraints: {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml b/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml index 9538edcb57150..fdd2a74632794 100644 --- a/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml +++ b/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml @@ -131,6 +131,10 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.patternIngester.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.patternIngester.tolerations }} tolerations: {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/templates/querier/deployment-querier.yaml b/production/helm/loki/templates/querier/deployment-querier.yaml index 80699f21fd162..3165d0dfd39e0 100644 --- a/production/helm/loki/templates/querier/deployment-querier.yaml +++ b/production/helm/loki/templates/querier/deployment-querier.yaml @@ -44,7 +44,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} {{- with .Values.querier.topologySpreadConstraints }} topologySpreadConstraints: {{- toYaml . | nindent 8 }} diff --git a/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml b/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml index 6eda5c51dfc0e..0b73fe8ae13b5 100644 --- a/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml +++ b/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml @@ -43,6 +43,12 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.queryFrontend.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} serviceAccountName: {{ include "loki.serviceAccountName" . }} {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml b/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml index 11b2829ebeec0..fbb1f284c6416 100644 --- a/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml +++ b/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml @@ -41,6 +41,12 @@ spec: {{- end }} app.kubernetes.io/part-of: memberlist spec: + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.queryScheduler.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} serviceAccountName: {{ include "loki.serviceAccountName" . }} {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/production/helm/loki/templates/ruler/statefulset-ruler.yaml b/production/helm/loki/templates/ruler/statefulset-ruler.yaml index 8153a8bb3827f..cff41890f01ce 100644 --- a/production/helm/loki/templates/ruler/statefulset-ruler.yaml +++ b/production/helm/loki/templates/ruler/statefulset-ruler.yaml @@ -38,6 +38,12 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.ruler.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} serviceAccountName: {{ include "loki.serviceAccountName" . }} {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 8c3c5c3bb6e3a..fda9cfdf561eb 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -1161,6 +1161,8 @@ enterpriseGateway: affinity: {} # -- Node selector for gateway Pods nodeSelector: {} + # -- Topology Spread Constraints for enterprise-gateway pods + topologySpreadConstraints: [] # -- Tolerations for gateway Pods tolerations: [] # -- Grace period to allow the gateway to shutdown before it is killed @@ -1973,6 +1975,8 @@ distributor: maxSurge: 0 # -- Node selector for distributor pods nodeSelector: {} + # -- Topology Spread Constraints for distributor pods + topologySpreadConstraints: [] # -- Tolerations for distributor pods tolerations: [] # -- Adds the appProtocol field to the distributor service. This allows distributor to work with istio protocol selection. @@ -2181,6 +2185,8 @@ queryFrontend: maxUnavailable: null # -- Node selector for query-frontend pods nodeSelector: {} + # -- Topology Spread Constraints for query-frontend pods + topologySpreadConstraints: [] # -- Tolerations for query-frontend pods tolerations: [] # -- Adds the appProtocol field to the queryFrontend service. This allows queryFrontend to work with istio protocol selection. @@ -2244,6 +2250,8 @@ queryScheduler: maxUnavailable: 1 # -- Node selector for query-scheduler pods nodeSelector: {} + # -- Topology Spread Constraints for query-scheduler pods + topologySpreadConstraints: [] # -- Tolerations for query-scheduler pods tolerations: [] # -- Set the optional grpc service protocol. Ex: "grpc", "http2" or "https" @@ -2308,6 +2316,8 @@ indexGateway: maxUnavailable: null # -- Node selector for index-gateway pods nodeSelector: {} + # -- Topology Spread Constraints for index-gateway pods + topologySpreadConstraints: [] # -- Tolerations for index-gateway pods tolerations: [] persistence: @@ -2796,6 +2806,8 @@ patternIngester: terminationGracePeriodSeconds: 30 # -- Node selector for pattern ingester pods nodeSelector: {} + # -- Topology Spread Constraints for pattern ingester pods + topologySpreadConstraints: [] # -- Tolerations for pattern ingester pods tolerations: [] # -- Set the optional grpc service protocol. Ex: "grpc", "http2" or "https" @@ -2904,6 +2916,8 @@ ruler: maxUnavailable: null # -- Node selector for ruler pods nodeSelector: {} + # -- Topology Spread Constraints for ruler pods + topologySpreadConstraints: [] # -- Tolerations for ruler pods tolerations: [] # -- DNSConfig for ruler pods