This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 356efa3c refact: improve startup for helm deployment (#2312)
356efa3c is described below
commit 356efa3c27cbeeece363489f9be453fd1b709f91
Author: Ji Bin <[email protected]>
AuthorDate: Fri Jun 24 12:29:15 2022 +0800
refact: improve startup for helm deployment (#2312)
- add mysql readiness probe check
- containers add init container wait mysql ready if requires db
connection
- make container's name shorter for better reading
Signed-off-by: Ji Bin <[email protected]>
Co-authored-by: Klesh Wong <[email protected]>
---
.github/workflows/deploy-test.yml | 29 ++++++++++++++++++++---------
deployment/helm/templates/deployments.yaml | 15 +++++++++++++--
deployment/helm/templates/statefulsets.yaml | 24 +++++++++++++++++++++---
deployment/helm/values.yaml | 8 ++++++++
4 files changed, 62 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/deploy-test.yml
b/.github/workflows/deploy-test.yml
index b256eca3..3e05c61c 100644
--- a/.github/workflows/deploy-test.yml
+++ b/.github/workflows/deploy-test.yml
@@ -59,15 +59,26 @@ jobs:
- name: Curl with endpoints
run: |
export NODE_IP=$(kubectl get nodes --namespace default -o
jsonpath="{.items[0].status.addresses[0].address}")
- # home
- curl --fail http://${NODE_IP}:30000
- # API for devlake
- curl --fail --silent --retry 10 --retry-delay 5 \
- http://${NODE_IP}:30000/api/blueprints
- # API for grafana
- curl --fail --silent --retry 10 --retry-delay 5 \
- http://${NODE_IP}:30001/api/health
-
+ failed=0
+ for retry in {1..10} ; do
+ failed=0
+ # home
+ curl --fail http://${NODE_IP}:30000 || failed=1
+ # API for devlake
+ curl --fail http://${NODE_IP}:30000/api/blueprints || failed=1
+ # API for grafana
+ curl --fail http://${NODE_IP}:30001/api/health || failed=1
+ if [ $failed -eq 0 ] ; then
+ break
+ else
+ sleep 3
+ fi
+ done
+ if [ $failed -ne 0 ] ; then
+ echo 'Test apis failed, please check logs from the PODS'
+ exit 1
+ fi
+
- name: Show logs for pods
if: ${{ always() }}
run: |
diff --git a/deployment/helm/templates/deployments.yaml
b/deployment/helm/templates/deployments.yaml
index 1b0243ab..b4893bcf 100644
--- a/deployment/helm/templates/deployments.yaml
+++ b/deployment/helm/templates/deployments.yaml
@@ -34,8 +34,19 @@ spec:
{{- include "devlake.selectorLabels" . | nindent 8 }}
devlakeComponent: grafana
spec:
+ initContainers:
+ - name: waiting-mysql-ready
+ image: "{{ .Values.alpine.image.repository }}:{{
.Values.alpine.image.tag }}"
+ imagePullPolicy: {{ .Values.alpine.image.pullPolicy }}
+ command:
+ - 'sh'
+ - '-c'
+ - |
+ until nc -z -w 2 {{ include "devlake.fullname" . }}-mysql 3306
&& echo mysql is ready ; do
+ sleep 2
+ done
containers:
- - name: {{ .Chart.Name }}-grafana
+ - name: grafana
image: "{{ .Values.grafana.image.repository }}:{{
.Values.grafana.image.tag }}"
imagePullPolicy: {{ .Values.grafana.image.pullPolicy }}
ports:
@@ -88,7 +99,7 @@ spec:
devlakeComponent: ui
spec:
containers:
- - name: {{ .Chart.Name }}-ui
+ - name: config-ui
image: "{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag }}"
imagePullPolicy: {{ .Values.ui.image.pullPolicy }}
ports:
diff --git a/deployment/helm/templates/statefulsets.yaml
b/deployment/helm/templates/statefulsets.yaml
index 0622e2b8..09c03e05 100644
--- a/deployment/helm/templates/statefulsets.yaml
+++ b/deployment/helm/templates/statefulsets.yaml
@@ -35,7 +35,7 @@ spec:
devlakeComponent: mysql
spec:
containers:
- - name: {{ .Chart.Name }}-mysql
+ - name: mysql
image: "{{ .Values.mysql.image.repository }}:{{
.Values.mysql.image.tag }}"
imagePullPolicy: {{ .Values.mysql.image.pullPolicy }}
ports:
@@ -50,6 +50,14 @@ spec:
- "mysqladmin ping -u root -p{{ .Values.mysql.rootPassword }}"
initialDelaySeconds: 60
timeoutSeconds: 30
+ readinessProbe:
+ exec:
+ command:
+ - "sh"
+ - "-c"
+ - "mysqladmin ping -u root -p{{ .Values.mysql.rootPassword }}"
+ initialDelaySeconds: 5
+ timeoutSeconds: 10
{{- with .Values.mysql.resources }}
resources:
{{- toYaml . | nindent 12 }}
@@ -87,7 +95,6 @@ spec:
---
# devlake
-# TODO: graceful startup: init container for waiting mysql ready
apiVersion: apps/v1
kind: StatefulSet
metadata:
@@ -106,8 +113,19 @@ spec:
{{- include "devlake.selectorLabels" . | nindent 8 }}
devlakeComponent: lake
spec:
+ initContainers:
+ - name: waiting-mysql-ready
+ image: "{{ .Values.alpine.image.repository }}:{{
.Values.alpine.image.tag }}"
+ imagePullPolicy: {{ .Values.alpine.image.pullPolicy }}
+ command:
+ - 'sh'
+ - '-c'
+ - |
+ until nc -z -w 2 {{ include "devlake.fullname" . }}-mysql 3306
&& echo mysql is ready ; do
+ sleep 2
+ done
containers:
- - name: {{ .Chart.Name }}-lake
+ - name: lake
image: "{{ .Values.lake.image.repository }}:{{
.Values.lake.image.tag }}"
imagePullPolicy: {{ .Values.lake.image.pullPolicy }}
ports:
diff --git a/deployment/helm/values.yaml b/deployment/helm/values.yaml
index c3c87232..f49181c0 100644
--- a/deployment/helm/values.yaml
+++ b/deployment/helm/values.yaml
@@ -116,6 +116,14 @@ ui:
affinity: {}
+
+# alpine image for some init containers
+alpine:
+ image:
+ repository: alpine
+ tag: 3.16
+ pullPolicy: IfNotPresent
+
service:
type: NodePort
# service port for grafana