Skip to content

Commit 9d32ec3

Browse files
authored
helm: make MySQL DB_URL extensible/overridable, wire Grafana datasource envs, and add smoke-test CI (#350)
* Add custom MySQL DSN query params feature - Introduce `DB_CUSTOM_PARAMS` in `configmap.yaml`. - Enhance `DB_URL` in `deployments.yaml` to include custom params. - Define `mysql.extraParams` in `values.yaml` for configuration. Signed-off-by: kahirokunn <okinakahiro@gmail.com> * Enable optional DB URL auto-assembly for MySQL Signed-off-by: kahirokunn <okinakahiro@gmail.com> * fix: Pass MySQL env vars to Grafana for datasource setup - Introduced `connectionConfigmapName` to optionally override the default ConfigMap name for better configurability. Signed-off-by: kahirokunn <okinakahiro@gmail.com> * Add Helm smoke test workflow Signed-off-by: kahirokunn <okinakahiro@gmail.com> * Link Secret and ConfigMap names in values.yaml Signed-off-by: kahirokunn <okinakahiro@gmail.com> * Add customizable probes for MySQL containers Signed-off-by: kahirokunn <okinakahiro@gmail.com> * fix(mysql): Resolve environment-dependent startup failures by switching MySQL probes to TCP Signed-off-by: kahirokunn <okinakahiro@gmail.com> --------- Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 72dbacc commit 9d32ec3

File tree

6 files changed

+134
-19
lines changed

6 files changed

+134
-19
lines changed

.github/workflows/smoke-test.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: DevLake Helm Smoke Test
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "**" ]
8+
9+
jobs:
10+
smoke-test:
11+
name: Smoke Test
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 50
14+
env:
15+
RELEASE_NAME: devlake
16+
NAMESPACE: devlake
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Set up Helm
22+
uses: azure/setup-helm@v4
23+
24+
- name: Create kind cluster
25+
uses: helm/kind-action@v1.12.0
26+
with:
27+
cluster_name: devlake-e2e
28+
29+
- name: Set up kubectl
30+
uses: azure/setup-kubectl@v4
31+
32+
- name: Add Helm repos
33+
run: |
34+
helm repo add grafana https://grafana.github.io/helm-charts
35+
helm repo update
36+
37+
- name: Build chart dependencies
38+
run: |
39+
helm dependency build charts/devlake
40+
41+
- name: Install DevLake chart
42+
run: |
43+
kubectl get events -n "$NAMESPACE" -w &
44+
kubectl get pods -n "$NAMESPACE" -w &
45+
ENCRYPTION_SECRET=$(openssl rand -base64 2000 | tr -dc 'A-Z' | fold -w 128 | head -n 1)
46+
helm install "$RELEASE_NAME" ./charts/devlake \
47+
--namespace "$NAMESPACE" \
48+
--create-namespace \
49+
--wait \
50+
--set lake.encryptionSecret.secret="${ENCRYPTION_SECRET}"
51+
52+
- name: Dump diagnostics on failure
53+
if: failure()
54+
run: |
55+
echo "=== Helm status for release ==="
56+
helm status "$RELEASE_NAME" -n "$NAMESPACE" || true
57+
echo "=== Kubernetes resources (all) ==="
58+
kubectl get all -n "$NAMESPACE" -o wide || true
59+
echo "=== Kubernetes events (latest 200) ==="
60+
kubectl get events -n "$NAMESPACE" --sort-by=.lastTimestamp | tail -n 200 || true
61+
echo "=== Describe deployments/statefulsets ==="
62+
kubectl describe deploy -n "$NAMESPACE" || true
63+
kubectl describe statefulset -n "$NAMESPACE" || true
64+
echo "=== Describe pods ==="
65+
kubectl describe pods -n "$NAMESPACE" || true
66+
echo "=== Logs from all pods (current and previous, last 200 lines) ==="
67+
for pod in $(kubectl get pods -n "$NAMESPACE" -o jsonpath='{.items[*].metadata.name}'); do
68+
echo "----- logs for ${pod} -----"
69+
kubectl logs -n "$NAMESPACE" "$pod" --all-containers --tail=200 || true
70+
echo "----- previous logs for ${pod} -----"
71+
kubectl logs -n "$NAMESPACE" "$pod" --all-containers --previous --tail=200 || true
72+
done

charts/devlake/templates/_helpers.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ The ui endpoint
105105
{{- end -}}
106106

107107
{{- define "devlake.mysql.configmap" -}}
108+
{{- if .Values.option.connectionConfigmapName -}}
109+
{{- .Values.option.connectionConfigmapName -}}
110+
{{- else -}}
108111
{{ include "devlake.fullname" . }}-config
109112
{{- end -}}
113+
{{- end -}}
110114

111115
{{- define "devlake.ui.auth.secret" -}}
112116
{{- if .Values.ui.basicAuth.secretName -}}

charts/devlake/templates/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ data:
3232
DB_CHARSET: "utf8mb4"
3333
DB_PARSE_TIME: "True"
3434
DB_LOCATION: "{{ .Values.commonEnvs.TZ }}"
35+
DB_CUSTOM_PARAMS: "{{ .Values.mysql.extraParams }}"
3536
{{- end }}

charts/devlake/templates/deployments.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ spec:
197197
env:
198198
- name: PORT
199199
value: "{{ .Values.lake.port }}"
200-
{{- if (eq .Values.option.database "mysql") }}
200+
{{- if and (eq .Values.option.database "mysql") (.Values.option.assembleDbUrl) }}
201201
- name: DB_URL
202-
value: "mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@$(MYSQL_SERVER):$(MYSQL_PORT)/$(MYSQL_DATABASE)?charset=$(DB_CHARSET)&parseTime=$(DB_PARSE_TIME)&loc=$(DB_LOCATION)"
202+
value: "mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@$(MYSQL_SERVER):$(MYSQL_PORT)/$(MYSQL_DATABASE)?charset=$(DB_CHARSET)&parseTime=$(DB_PARSE_TIME)&loc=$(DB_LOCATION){{ .Values.mysql.extraParams }}"
203203
{{- end }}
204204
{{- range $key1, $value1 := .Values.lake.envs }}
205205
- name: "{{ tpl $key1 $ }}"

charts/devlake/templates/statefulsets.yaml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,18 @@ spec:
6969
- name: mysql
7070
containerPort: 3306
7171
protocol: TCP
72+
{{- with .Values.mysql.startupProbe }}
73+
startupProbe:
74+
{{- toYaml . | nindent 12 }}
75+
{{- end }}
76+
{{- with .Values.mysql.livenessProbe }}
7277
livenessProbe:
73-
exec:
74-
command:
75-
- "sh"
76-
- "-c"
77-
- "mysqladmin ping -u root -p$MYSQL_ROOT_PASSWORD"
78-
initialDelaySeconds: 60
79-
timeoutSeconds: 30
78+
{{- toYaml . | nindent 12 }}
79+
{{- end }}
80+
{{- with .Values.mysql.readinessProbe }}
8081
readinessProbe:
81-
exec:
82-
command:
83-
- "sh"
84-
- "-c"
85-
- "mysqladmin ping -u root -p$MYSQL_ROOT_PASSWORD"
86-
initialDelaySeconds: 5
87-
timeoutSeconds: 10
82+
{{- toYaml . | nindent 12 }}
83+
{{- end }}
8884
{{- with .Values.mysql.resources }}
8985
resources:
9086
{{- toYaml . | nindent 12 }}

charts/devlake/values.yaml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ mysql:
4747
# the database for devlake
4848
database: lake
4949

50+
# extra MySQL DSN query params appended to DB_URL.
51+
# Note: include a leading '&' yourself. Empty string means no change.
52+
# example: "&tls=skip-verify" or "&tls=skip-verify&autocommit=true"
53+
extraParams: ""
54+
5055
# root password for mysql, only used when use_external=false
5156
rootPassword: admin
5257

@@ -90,6 +95,32 @@ mysql:
9095

9196
podAnnotations: {}
9297

98+
# Probes for MySQL container
99+
startupProbe:
100+
exec: &mysql_ping_exec
101+
command:
102+
- "sh"
103+
- "-c"
104+
- "mysqladmin ping --protocol=TCP -h 127.0.0.1 -u root -p$MYSQL_ROOT_PASSWORD"
105+
initialDelaySeconds: 120
106+
periodSeconds: 10
107+
timeoutSeconds: 10
108+
failureThreshold: 60
109+
110+
livenessProbe:
111+
exec: *mysql_ping_exec
112+
initialDelaySeconds: 60
113+
periodSeconds: 10
114+
timeoutSeconds: 30
115+
failureThreshold: 5
116+
117+
readinessProbe:
118+
exec: *mysql_ping_exec
119+
initialDelaySeconds: 5
120+
periodSeconds: 5
121+
timeoutSeconds: 10
122+
failureThreshold: 3
123+
93124
service:
94125
type: "ClusterIP"
95126
nodePort: ""
@@ -164,9 +195,13 @@ grafana:
164195
server:
165196
serve_from_subpath: "true"
166197
root_url: "%(protocol)s://%(domain)s/grafana"
167-
#the secret name should be as same as .Values.option.connectionSecretName
198+
# the Secret name should be the same as .Values.option.connectionSecretName
168199
envFromSecrets:
169-
- name: "devlake-mysql-auth"
200+
- name: &devlake_mysql_auth "devlake-mysql-auth"
201+
# the ConfigMap name should be the same as .Values.option.connectionConfigmapName
202+
extraEnvFrom:
203+
- configMapRef:
204+
name: &devlake_mysql_auth_config "devlake-mysql-auth-config"
170205
#keep grafana timezone same as other pods, which is set by .Values.commonEnvs.TZ
171206
env:
172207
TZ: "UTC"
@@ -430,8 +465,15 @@ option:
430465
# database type, supported: [mysql]
431466
database: mysql
432467
# the existing k8s secret name of db connection auth. The secret name should be as same as .Values.grafana.envFromSecret
433-
connectionSecretName: "devlake-mysql-auth"
468+
connectionSecretName: *devlake_mysql_auth
469+
# Optional: override the ConfigMap name for non-sensitive DB envs used across components
470+
# Default is a fixed name to align references from subcharts
471+
connectionConfigmapName: *devlake_mysql_auth_config
434472
autoCreateSecret: true
473+
# If true, the chart assembles DB_URL automatically for MySQL. Set to false
474+
# to disable auto-assembly and provide DB_URL yourself via `lake.envs` or
475+
# an external secret referenced by `lake.extraEnvsFromSecret`.
476+
assembleDbUrl: true
435477

436478
# Define some extra resources to be created
437479
# This section is useful when you need ExternalResource or Secrets, etc.

0 commit comments

Comments
 (0)