Skip to content

Commit

Permalink
refactor zk script and add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie committed Oct 17, 2024
1 parent 3e86233 commit 9471421
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion addons-cluster/zookeeper/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion addons/zookeeper/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords:
- middleware

maintainers:
- name: kubeblocks
- name: kubeJocker
url: https://github.com/apecloud/kubeblocks/
- name: kissycn
url: https://github.com/kissycn
Expand Down
28 changes: 28 additions & 0 deletions addons/zookeeper/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
8 changes: 4 additions & 4 deletions addons/zookeeper/templates/cmpd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion addons/zookeeper/templates/config-configmap.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion addons/zookeeper/templates/configconstraint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 4 additions & 2 deletions addons/zookeeper/templates/scripts.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
{{- .Files.Get "scripts/startup.sh" | nindent 4 }}
roleprobe.sh: |-
{{- .Files.Get "scripts/roleprobe.sh" | nindent 4 }}

0 comments on commit 9471421

Please sign in to comment.