Skip to content

Commit

Permalink
feat(query): support workload type deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Mar 29, 2024
1 parent 8e5ce32 commit 0433870
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 17 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ concurrency:

jobs:
k3d:
strategy:
matrix:
workload:
- StatefulSet
- Deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -59,7 +64,7 @@ jobs:
--set bootstrap=true \
--set replicaCount=3 \
--set persistence.size=1Gi \
--wait
--wait --timeout 2m0s
kubectl get pods -n databend-meta
- name: Install MinIO
Expand All @@ -68,7 +73,7 @@ jobs:
helm upgrade --install minio minio/minio \
--namespace minio --create-namespace \
--values tests/minio.yaml \
--wait
--wait --timeout 1m0s
- name: Install Databend Query
shell: bash
Expand All @@ -82,7 +87,8 @@ jobs:
helm upgrade --install cluster1 . \
--namespace tenant1 --create-namespace \
--values ../../tests/query-with-minio.yaml \
--wait
--set workload=${{ matrix.workload }} \
--wait --timeout 1m0s
kubectl get pods -n tenant1
- name: Checking Cluster Status
Expand Down
4 changes: 2 additions & 2 deletions charts/databend-meta/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.3
version: 0.7.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1.2.279"
appVersion: "v1.2.371"

dependencies:
- name: common
Expand Down
4 changes: 2 additions & 2 deletions charts/databend-query/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.8.3
version: 0.9.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1.2.279"
appVersion: "v1.2.371"

dependencies:
- name: common
Expand Down
5 changes: 1 addition & 4 deletions charts/databend-query/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ data:
config.toml: |-
# databend query config
[query]
max_active_sessions = {{ .Values.config.query.maxActiveSessions | default 1024 }}
wait_timeout_mills = {{ .Values.config.query.waitTimeoutMills | default 5000 }}
tenant_id = {{ .Values.config.query.tenantId | default .Release.Name | quote }}
cluster_id = {{ .Values.config.query.clusterId | quote }}
Expand Down Expand Up @@ -83,7 +80,7 @@ data:
{{- end }}
{{- end }}
{{- if .Values.cache.enabled }}
{{- if and .Values.cache.enabled (eq (lower .Values.workload) "statefulset") }}
[cache]
data_cache_storage = "disk"
[cache.disk]
Expand Down
124 changes: 124 additions & 0 deletions charts/databend-query/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{{- if eq (lower .Values.workload) "deployment" }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "databend-query.fullname" . }}
labels:
{{- include "databend-query.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "databend-query.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "databend-query.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "databend-query.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | trim | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
command:
- /databend-query
- -c
- /etc/databend-query/config.toml
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
{{- range $key, $val := .Values.service.ports }}
- name: {{ $key }}
containerPort: {{ $val}}
{{- end }}
livenessProbe:
httpGet:
path: /v1/health
port: admin
readinessProbe:
httpGet:
path: /v1/health
port: admin
initialDelaySeconds: 5
periodSeconds: 15
failureThreshold: 3
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: QUERY_METRIC_API_ADDRESS
value: "$(POD_IP):{{ .Values.service.ports.metric | default 7070 }}"
- name: QUERY_ADMIN_API_ADDRESS
value: "$(POD_IP):{{ .Values.service.ports.admin | default 8080 }}"
- name: QUERY_FLIGHT_API_ADDRESS
value: "$(POD_IP):{{ .Values.service.ports.flight | default 9090 }}"
- name: QUERY_HTTP_HANDLER_HOST
value: 0.0.0.0
- name: QUERY_HTTP_HANDLER_PORT
value: {{ .Values.service.ports.http | default 8000 | quote }}
- name: QUERY_FLIGHT_SQL_HANDLER_HOST
value: 0.0.0.0
- name: QUERY_FLIGHT_SQL_HANDLER_PORT
value: {{ .Values.service.ports.flightsql | default 8900 | quote }}
- name: QUERY_MYSQL_HANDLER_HOST
value: 0.0.0.0
- name: QUERY_MYSQL_HANDLER_PORT
value: {{ .Values.service.ports.mysql | default 3307 | quote }}
- name: QUERY_CLICKHOUSE_HTTP_HANDLER_HOST
value: 0.0.0.0
- name: QUERY_CLICKHOUSE_HTTP_HANDLER_PORT
value: {{ .Values.service.ports.ckhttp | default 8124 | quote }}
{{- with .Values.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config
# Note: subPath volume mount will not receive ConfigMap update.
mountPath: /etc/databend-query
{{- if .Values.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "databend-query.fullname" .}}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/databend-query/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ spec:
{{- end }}
selector:
{{- include "databend-query.selectorLabels" . | nindent 4 }}
{{- if eq (lower .Values.workload) "statefulset" }}
statefulset.kubernetes.io/pod-name: {{ include "databend-query.fullname" . }}-0
{{- end }}
5 changes: 4 additions & 1 deletion charts/databend-query/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- if eq (lower .Values.workload) "statefulset" }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand Down Expand Up @@ -94,7 +96,7 @@ spec:
- name: QUERY_CLICKHOUSE_HTTP_HANDLER_HOST
value: 0.0.0.0
- name: QUERY_CLICKHOUSE_HTTP_HANDLER_PORT
value: {{ .Values.service.ports.ckhttp |default 8124 | quote }}
value: {{ .Values.service.ports.ckhttp | default 8124 | quote }}
{{- with .Values.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -136,3 +138,4 @@ spec:
requests:
storage: {{ .Values.cache.maxBytes | quote }}
{{- end }}
{{- end }}
12 changes: 7 additions & 5 deletions charts/databend-query/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

replicaCount: 1

# Could be StatefulSet or Deployment
workload: StatefulSet

image:
repository: datafuselabs/databend-query
pullPolicy: IfNotPresent
Expand Down Expand Up @@ -50,15 +53,15 @@ serviceMonitor:
config:
# [query]
query:
maxActiveSessions: 256
waitTimeoutMills: 5000

tenantId: ""
clusterId: default

managementMode: false
jwtKeyFile: ""

extra:
max_active_sessions: 256

# NOTE: user `root` is already built-in, will be ignored if defined here
users: []
# - name: databend
Expand All @@ -67,8 +70,6 @@ config:
# authType: double_sha1_password
# authString: 3081f32caef285c232d066033c89a78d88a6d8a5 # databend

extra: {}

# [log]
log:
file:
Expand Down Expand Up @@ -115,6 +116,7 @@ config:
access_key_id: ""
access_key_secret: ""

# NOTE: only for StatefulSet
cache:
enabled: false
path: "/var/lib/databend/cache"
Expand Down
2 changes: 2 additions & 0 deletions examples/query-cluster-as-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
replicaCount: 3
workload: Deployment

0 comments on commit 0433870

Please sign in to comment.