From 9471421e1b8f883402462da59a3cb79426b8ecb4 Mon Sep 17 00:00:00 2001 From: Y-Rookie Date: Thu, 17 Oct 2024 11:31:25 +0800 Subject: [PATCH] refactor zk script and add ut --- .../zookeeper/templates/cluster.yaml | 2 +- addons/zookeeper/Chart.yaml | 2 +- addons/zookeeper/templates/_helpers.tpl | 28 +++++++++++++++++++ addons/zookeeper/templates/cmpd.yaml | 8 +++--- .../zookeeper/templates/config-configmap.yaml | 2 +- .../zookeeper/templates/configconstraint.yaml | 2 +- ...mfigmap.yaml => log-config-configmap.yaml} | 2 +- addons/zookeeper/templates/scripts.yaml | 6 ++-- 8 files changed, 41 insertions(+), 11 deletions(-) rename addons/zookeeper/templates/{comfigmap.yaml => log-config-configmap.yaml} (83%) diff --git a/addons-cluster/zookeeper/templates/cluster.yaml b/addons-cluster/zookeeper/templates/cluster.yaml index 52c7fd149..f7212297a 100644 --- a/addons-cluster/zookeeper/templates/cluster.yaml +++ b/addons-cluster/zookeeper/templates/cluster.yaml @@ -17,7 +17,7 @@ spec: {{- include "kblib.componentResources" . | indent 6 }} env: - name: ZOOKEEPER_IMAGE_VERSION - value: "{{ .Values.serviceVersion }}" + value: "{{ .Values.version }}" volumeClaimTemplates: - name: data spec: diff --git a/addons/zookeeper/Chart.yaml b/addons/zookeeper/Chart.yaml index 950d5e75a..f49f72a9e 100644 --- a/addons/zookeeper/Chart.yaml +++ b/addons/zookeeper/Chart.yaml @@ -16,7 +16,7 @@ keywords: - middleware maintainers: - - name: kubeblocks + - name: kubeJocker url: https://github.com/apecloud/kubeblocks/ - name: kissycn url: https://github.com/kissycn diff --git a/addons/zookeeper/templates/_helpers.tpl b/addons/zookeeper/templates/_helpers.tpl index 6a0c0c952..d872806c6 100644 --- a/addons/zookeeper/templates/_helpers.tpl +++ b/addons/zookeeper/templates/_helpers.tpl @@ -75,3 +75,31 @@ Define zookeeper component definition regular expression name prefix {{- define "zookeeper.cmpdRegexpPattern" -}} ^zookeeper-* {{- end -}} + +{{/* +Define zookeeper scripts template name +*/}} +{{- define "zookeeper.scriptsTplName" -}} +zookeeper-scripts +{{- end -}} + +{{/* +Define zookeeper config template name +*/}} +{{- define "zookeeper.configTplName" -}} +zookeeper-config-template +{{- end -}} + +{{/* +Define zookeeper config constraint name +*/}} +{{- define "zookeeper.configConstraintName" -}} +zookeeper-config-constraints +{{- end -}} + +{{/* +Define zookeeper log config template name +*/}} +{{- define "zookeeper.logConfigTplName" -}} +zookeeper-log-config-template +{{- end -}} diff --git a/addons/zookeeper/templates/cmpd.yaml b/addons/zookeeper/templates/cmpd.yaml index 1056f69b1..f8b6d2966 100644 --- a/addons/zookeeper/templates/cmpd.yaml +++ b/addons/zookeeper/templates/cmpd.yaml @@ -61,22 +61,22 @@ spec: value: {{ .Values.zookeeper.dataLogDir }} scripts: - name: zookeeper-scripts - templateRef: {{ include "zookeeper.name" . }}-scripts + templateRef: {{ include "zookeeper.scriptsTplName" . }} volumeName: scripts namespace: {{ .Release.Namespace }} defaultMode: 0755 configs: - name: zookeeper-config namespace: {{ .Release.Namespace }} - templateRef: {{ include "zookeeper.name" . }}-config-template - constraintRef: {{ include "zookeeper.name" . }}-config-constraints + templateRef: {{ include "zookeeper.configTplName" . }} + constraintRef: {{ include "zookeeper.configConstraintName" . }} volumeName: config defaultMode: 0755 reRenderResourceTypes: - hscale - name: zookeeper-log namespace: {{ .Release.Namespace }} - templateRef: {{ include "zookeeper.name" . }}-configmap + templateRef: {{ include "zookeeper.logConfigTplName" . }} volumeName: config-log lifecycleActions: roleProbe: diff --git a/addons/zookeeper/templates/config-configmap.yaml b/addons/zookeeper/templates/config-configmap.yaml index 08c50202a..4048d453a 100644 --- a/addons/zookeeper/templates/config-configmap.yaml +++ b/addons/zookeeper/templates/config-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "zookeeper.name" . }}-config-template + name: {{ include "zookeeper.configTplName" . }} labels: {{- include "zookeeper.labels" . | nindent 4 }} data: diff --git a/addons/zookeeper/templates/configconstraint.yaml b/addons/zookeeper/templates/configconstraint.yaml index 372b814e7..78cce4b2d 100644 --- a/addons/zookeeper/templates/configconstraint.yaml +++ b/addons/zookeeper/templates/configconstraint.yaml @@ -2,7 +2,7 @@ apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: {{ include "zookeeper.name" . }}-config-constraints + name: {{ include "zookeeper.configConstraintName" . }} labels: {{- include "zookeeper.labels" . | nindent 4 }} spec: diff --git a/addons/zookeeper/templates/comfigmap.yaml b/addons/zookeeper/templates/log-config-configmap.yaml similarity index 83% rename from addons/zookeeper/templates/comfigmap.yaml rename to addons/zookeeper/templates/log-config-configmap.yaml index 142278196..ceed9286a 100644 --- a/addons/zookeeper/templates/comfigmap.yaml +++ b/addons/zookeeper/templates/log-config-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "zookeeper.name" . }}-configmap + name: {{ include "zookeeper.logConfigTplName" . }} labels: {{- include "zookeeper.labels" . | nindent 4 }} data: diff --git a/addons/zookeeper/templates/scripts.yaml b/addons/zookeeper/templates/scripts.yaml index 5b990d685..31fc7d089 100644 --- a/addons/zookeeper/templates/scripts.yaml +++ b/addons/zookeeper/templates/scripts.yaml @@ -1,9 +1,11 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "zookeeper.name" . }}-scripts + name: {{ include "zookeeper.scriptsTplName" . }} labels: {{- include "zookeeper.labels" . | nindent 4 }} data: startup.sh: |- - {{- .Files.Get "scripts/startup.sh" | nindent 4 }} \ No newline at end of file + {{- .Files.Get "scripts/startup.sh" | nindent 4 }} + roleprobe.sh: |- + {{- .Files.Get "scripts/roleprobe.sh" | nindent 4 }} \ No newline at end of file