Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adapt rabbitmq addon for API v1.0 #1107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions addons/rabbitmq/config/rabbitmq-env.tpl

This file was deleted.

40 changes: 13 additions & 27 deletions addons/rabbitmq/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,27 @@ app.kubernetes.io/name: {{ include "rabbitmq.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/*
Return rabbitmq service port
Common annotations
*/}}
{{- define "rabbitmq.service.port" -}}
{{- .Values.primary.service.ports.rabbitmq -}}
{{- end -}}
{{- define "rabbitmq.annotations" -}}
helm.sh/resource-policy: keep
{{- end }}

{{/*
Get the password key.
Define rabbitmq component definition name prefix
*/}}
{{- define "rabbitmq.password" -}}
{{- if or (.Release.IsInstall) (not (lookup "apps.kubeblocks.io/v1alpha1" "ClusterDefinition" "" "rabbitmq")) -}}
{{ .Values.auth.password | default "$(RANDOM_PASSWD)"}}
{{- else -}}
{{ index (lookup "apps.kubeblocks.io/v1alpha1" "ClusterDefinition" "" "rabbitmq").spec.connectionCredential "password"}}
{{- end }}
{{- end }}
{{- define "rabbitmq.cmpdNamePrefix" -}}
{{- printf "rabbitmq-" -}}
{{- end -}}

{{/*
Check if cluster version is enabled, if enabledClusterVersions is empty, return true,
otherwise, check if the cluster version is in the enabledClusterVersions list, if yes, return true,
else return false.
Parameters: cvName, values
Define rabbitmq component definition name
*/}}
{{- define "rabbitmq.isClusterVersionEnabled" -}}
{{- $cvName := .cvName -}}
{{- $enabledClusterVersions := .values.enabledClusterVersions -}}
{{- if eq (len $enabledClusterVersions) 0 -}}
{{- true -}}
{{- define "rabbitmq.cmpdName" -}}
{{- if eq (len .Values.resourceNamePrefix) 0 -}}
{{ include "rabbitmq.cmpdNamePrefix" . }}{{ .Chart.Version }}
{{- else -}}
{{- range $enabledClusterVersions -}}
{{- if eq $cvName . -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{ .Values.resourceNamePrefix}}-{{ .Chart.Version }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about {{ .Values.resourceNamePrefix}}-rabbitmq-{{ .Chart.Version }}?

{{- end -}}
{{- end -}}
13 changes: 13 additions & 0 deletions addons/rabbitmq/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: apps.kubeblocks.io/v1
kind: ClusterDefinition
metadata:
name: rabbitmq
labels:
{{- include "rabbitmq.labels" . | nindent 4 }}
spec:
topologies:
- name: clustermode
components:
- name: rabbitmq
compDef: {{ include "rabbitmq.cmpdNamePrefix" . }}
default: true
6 changes: 4 additions & 2 deletions addons/rabbitmq/templates/componentdefinition.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
apiVersion: apps.kubeblocks.io/v1
kind: ComponentDefinition
metadata:
name: {{ include "rabbitmq.componentDefName" . }}
name: {{ include "rabbitmq.cmpdName" . }}
labels:
{{- include "rabbitmq.labels" . | nindent 4 }}
annotations:
{{- include "rabbitmq.annotations" . | nindent 4 }}
spec:
provider: kubeblocks.io
description: RabbitMQ is a reliable and mature messaging and streaming broker.
Expand Down Expand Up @@ -69,7 +71,7 @@ spec:
- name: RABBITMQ_USE_LONGNAME
value: "true"
- name: RABBITMQ_NODENAME
value: rabbit@$(KB_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)
value: rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)
- name: K8S_HOSTNAME_SUFFIX
value: .$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}
Expand Down
2 changes: 1 addition & 1 deletion addons/rabbitmq/templates/componentversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
compatibilityRules:
- compDefs:
- {{ include "rabbitmq.componentDefName" . }}
- {{ include "rabbitmq.cmpdNamePrefix" . }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern can't match the comp if .Values.resourceNamePrefix is not empty.

releases:
- 3.13.2
- 3.12.14
Expand Down
13 changes: 0 additions & 13 deletions addons/rabbitmq/templates/scriptstemplate.yaml

This file was deleted.

Loading