From cf3d1cce9e07cbf3e0a0ea7dd66c9b280a5c6d3a Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Tue, 6 Aug 2024 14:56:21 +0800 Subject: [PATCH 1/3] add switch to enable lb --- charts/databend-query/templates/ingress.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/databend-query/templates/ingress.yaml b/charts/databend-query/templates/ingress.yaml index 879fb6e..376bf81 100644 --- a/charts/databend-query/templates/ingress.yaml +++ b/charts/databend-query/templates/ingress.yaml @@ -6,6 +6,9 @@ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} {{- end }} {{- end }} +{{- if .Values.ingress.loadBalanceByRouteHint }} + {{- $_ := set .Values.ingress.annotations "nginx.ingress.kubernetes.io/upstream-hash-by" "$http_x_databend_route_hint" }} +{{- end }} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1 {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} From b35e5a0c6cc0338fc3a6c1d1f149ca3986fdcbdd Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Tue, 6 Aug 2024 15:59:42 +0800 Subject: [PATCH 2/3] rename to loadbalance queries --- charts/databend-query/templates/ingress.yaml | 2 +- charts/databend-query/values.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/databend-query/templates/ingress.yaml b/charts/databend-query/templates/ingress.yaml index 376bf81..bd6edcb 100644 --- a/charts/databend-query/templates/ingress.yaml +++ b/charts/databend-query/templates/ingress.yaml @@ -6,7 +6,7 @@ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} {{- end }} {{- end }} -{{- if .Values.ingress.loadBalanceByRouteHint }} +{{- if .Values.ingress.loadBalanceQueries }} {{- $_ := set .Values.ingress.annotations "nginx.ingress.kubernetes.io/upstream-hash-by" "$http_x_databend_route_hint" }} {{- end }} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} diff --git a/charts/databend-query/values.yaml b/charts/databend-query/values.yaml index ee2b5e5..32c27f2 100644 --- a/charts/databend-query/values.yaml +++ b/charts/databend-query/values.yaml @@ -150,6 +150,7 @@ cache: ingress: enabled: false + loadBalanceQueries: false className: "" annotations: {} # kubernetes.io/ingress.class: nginx From 22d6ea39b19808f38733e51270d1832aed317e85 Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Tue, 6 Aug 2024 16:23:12 +0800 Subject: [PATCH 3/3] fix --- charts/databend-query/templates/ingress.yaml | 2 +- charts/databend-query/templates/service.yaml | 2 +- charts/databend-query/values.yaml | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/charts/databend-query/templates/ingress.yaml b/charts/databend-query/templates/ingress.yaml index bd6edcb..ec0658f 100644 --- a/charts/databend-query/templates/ingress.yaml +++ b/charts/databend-query/templates/ingress.yaml @@ -6,7 +6,7 @@ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} {{- end }} {{- end }} -{{- if .Values.ingress.loadBalanceQueries }} +{{- if .Values.enableLoadBalance }} {{- $_ := set .Values.ingress.annotations "nginx.ingress.kubernetes.io/upstream-hash-by" "$http_x_databend_route_hint" }} {{- end }} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} diff --git a/charts/databend-query/templates/service.yaml b/charts/databend-query/templates/service.yaml index 335eb90..a91f876 100644 --- a/charts/databend-query/templates/service.yaml +++ b/charts/databend-query/templates/service.yaml @@ -19,7 +19,7 @@ spec: {{- end }} selector: {{- include "databend-query.selectorLabels" . | nindent 4 }} - {{- if eq (lower .Values.workload) "statefulset" }} + {{- if and (eq .Values.workload "statefulset") (not .Values.enableLoadBalance) }} statefulset.kubernetes.io/pod-name: {{ include "databend-query.fullname" . }}-0 {{- end }} {{- with .Values.service.sessionAffinity }} diff --git a/charts/databend-query/values.yaml b/charts/databend-query/values.yaml index 32c27f2..2b91644 100644 --- a/charts/databend-query/values.yaml +++ b/charts/databend-query/values.yaml @@ -7,6 +7,10 @@ replicaCount: 1 # Could be StatefulSet or Deployment workload: StatefulSet +# By default, the queries are routed to the first node in the StatefulSet, and this node is considered +# as the coordinator. If you want to enable load balance queries across nodes, set this to true. +enableLoadBalance: false + image: repository: datafuselabs/databend-query pullPolicy: IfNotPresent @@ -150,7 +154,6 @@ cache: ingress: enabled: false - loadBalanceQueries: false className: "" annotations: {} # kubernetes.io/ingress.class: nginx