This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 3166ad8d5 [INLONG-5179][Kubernetes] Add external mysql judgement for
manager, audit and tube-manager (#5180)
3166ad8d5 is described below
commit 3166ad8d551b789fafd4a61b9e431b9cc634172c
Author: Lucas <[email protected]>
AuthorDate: Sat Jul 23 12:09:59 2022 +0800
[INLONG-5179][Kubernetes] Add external mysql judgement for manager, audit
and tube-manager (#5180)
---
docker/kubernetes/templates/_helpers.tpl | 11 +++++++++++
docker/kubernetes/templates/audit-statefulset.yaml | 10 +++++++---
docker/kubernetes/templates/manager-statefulset.yaml | 10 +++++++---
docker/kubernetes/templates/tubemq-manager-statefulset.yaml | 10 +++++++---
4 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/docker/kubernetes/templates/_helpers.tpl
b/docker/kubernetes/templates/_helpers.tpl
index 765c8ba9b..12feaab0c 100644
--- a/docker/kubernetes/templates/_helpers.tpl
+++ b/docker/kubernetes/templates/_helpers.tpl
@@ -148,6 +148,17 @@ Define the mysql username
{{- end -}}
{{- end -}}
+{{/*
+Define the mysql count
+*/}}
+{{- define "inlong.mysql.count" -}}
+{{- if .Values.external.mysql.enabled -}}
+1
+{{- else -}}
+{{ .Values.mysql.replicas }}
+{{- end -}}
+{{- end -}}
+
{{/*
Define the zookeeper hostname
*/}}
diff --git a/docker/kubernetes/templates/audit-statefulset.yaml
b/docker/kubernetes/templates/audit-statefulset.yaml
index 2f9a85e07..3bcb113a3 100644
--- a/docker/kubernetes/templates/audit-statefulset.yaml
+++ b/docker/kubernetes/templates/audit-statefulset.yaml
@@ -63,15 +63,19 @@ spec:
command: [ "/bin/sh", "-c" ]
args:
- |
- count={{ .Values.mysql.replicas }}
+ count={{ template "inlong.mysql.count" . }}
for i in $(seq 0 $(expr $count - 1))
do
+ {{- if .Values.external.mysql.enabled }}
+ host="{{ template "inlong.mysql.hostname" . }}"
+ {{- else }}
replica="{{ template "inlong.fullname" . }}-{{
.Values.mysql.component }}-$i"
host="$replica.{{ template "inlong.mysql.hostname" . }}"
- port={{ .Values.mysql.port }}
+ {{- end }}
+ port={{ template "inlong.mysql.port" . }}
until nc -z $host $port 2>/dev/null
do
- echo "waiting for $replica to be ready"
+ echo "waiting for host:$host port:$port to be ready"
sleep 3
done
done
diff --git a/docker/kubernetes/templates/manager-statefulset.yaml
b/docker/kubernetes/templates/manager-statefulset.yaml
index 7d674de26..8c2bed6c8 100644
--- a/docker/kubernetes/templates/manager-statefulset.yaml
+++ b/docker/kubernetes/templates/manager-statefulset.yaml
@@ -63,15 +63,19 @@ spec:
command: [ "/bin/sh", "-c" ]
args:
- |-
- count={{ .Values.mysql.replicas }}
+ count={{ template "inlong.mysql.count" . }}
for i in $(seq 0 $(expr $count - 1))
do
+ {{- if .Values.external.mysql.enabled }}
+ host="{{ template "inlong.mysql.hostname" . }}"
+ {{- else }}
replica="{{ template "inlong.fullname" . }}-{{
.Values.mysql.component }}-$i"
host="$replica.{{ template "inlong.mysql.hostname" . }}"
- port={{ .Values.mysql.port }}
+ {{- end }}
+ port={{ template "inlong.mysql.port" . }}
until nc -z $host $port 2>/dev/null
do
- echo "waiting for $replica to be ready"
+ echo "waiting for host:$host port:$port to be ready"
sleep 3
done
done
diff --git a/docker/kubernetes/templates/tubemq-manager-statefulset.yaml
b/docker/kubernetes/templates/tubemq-manager-statefulset.yaml
index 6bf1df656..a79263404 100644
--- a/docker/kubernetes/templates/tubemq-manager-statefulset.yaml
+++ b/docker/kubernetes/templates/tubemq-manager-statefulset.yaml
@@ -63,15 +63,19 @@ spec:
command: [ "/bin/sh", "-c" ]
args:
- |
- count={{ .Values.mysql.replicas }}
+ count={{ template "inlong.mysql.count" . }}
for i in $(seq 0 $(expr $count - 1))
do
+ {{- if .Values.external.mysql.enabled }}
+ host="{{ template "inlong.mysql.hostname" . }}"
+ {{- else }}
replica="{{ template "inlong.fullname" . }}-{{
.Values.mysql.component }}-$i"
host="$replica.{{ template "inlong.mysql.hostname" . }}"
- port={{ .Values.mysql.port }}
+ {{- end }}
+ port={{ template "inlong.mysql.port" . }}
until nc -z $host $port 2>/dev/null
do
- echo "waiting for $replica to be ready"
+ echo "waiting for host:$host port:$port to be ready"
sleep 3
done
done