Skip to content

Commit 5425131

Browse files
[rabbitmq]: add option to handle definitions via chart (CloudPirates-io#286)
* [rabbitmq]: add option to handle definitions via chart * Update CHANGELOG.md Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * [rabbitmq]: bump up chart version --------- Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Gasper Oblak <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent b9ba642 commit 5425131

File tree

8 files changed

+276
-43
lines changed

8 files changed

+276
-43
lines changed

charts/rabbitmq/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## 0.3.2 (2025-10-09)
44

5-
* [mongodb] feat: add metrics exporter ([#243](https://github.com/CloudPirates-io/helm-charts/pull/243))
5+
* [rabbitmq]: add option to handle definitions via chart ([#286](https://github.com/CloudPirates-io/helm-charts/pull/286))

charts/rabbitmq/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: rabbitmq
33
description: A messaging broker that implements the Advanced Message Queuing Protocol (AMQP)
44
type: application
5-
version: 0.3.2
5+
version: 0.3.3
66
appVersion: "4.1.4"
77
keywords:
88
- rabbitmq

charts/rabbitmq/README.md

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ The following table lists the configurable parameters of the RabbitMQ chart and
102102
| `podLabels` | Labels to attach to pods | `{}` |
103103
| `statefulsetAnnotations` | Annotations for StatefulSet | `{}` |
104104

105+
| Parameter | Description | Default |
106+
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
107+
| `definitions.enabled` | Enable loading of RabbitMQ definitions on startup. When `true`, definitions will be loaded at container boot. | `false` |
108+
| `definitions.existingConfigMap` | Name of an existing ConfigMap containing RabbitMQ definitions (e.g., created via `kubectl create configmap rmq-defs --from-file=defs.json`). | `""` |
109+
| `definitions.existingConfigMapKey` | Key in the existing ConfigMap containing the RabbitMQ definitions JSON file. | `defs.json` |
110+
| `definitions.users` | Array of RabbitMQ users to create. | `[]` |
111+
| `definitions.vhosts` | Array of RabbitMQ virtual hosts to create. | `[]` |
112+
| `definitions.permissions` | Array of RabbitMQ permissions to set per vhost. | `[]` |
113+
| `definitions.queues` | Array of RabbitMQ queues to create. | `[]` |
114+
| `definitions.exchanges` | Array of RabbitMQ exchanges to create. | `[]` |
115+
| `definitions.bindings` | Array of RabbitMQ bindings to create. | `[]` |
116+
| `definitions.parameters` | Array of RabbitMQ parameters to create. | `[]` |
117+
| `definitions.global_parameters` | Array of RabbitMQ global parameters to create. | `[]` |
118+
| `definitions.topic_permissions` | Array of RabbitMQ topic permissions to create. | `[]` |
119+
| `definitions.policies` | Array of RabbitMQ policies to create. | `[]` |
105120

106121
### Service configuration
107122

@@ -153,8 +168,8 @@ The following table lists the configurable parameters of the RabbitMQ chart and
153168

154169
## Plugin configuration
155170

156-
| Parameter | Description | Default |
157-
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
171+
| Parameter | Description | Default |
172+
| ---------------- | ------------------------------------------------------------ | ------- |
158173
| `installPlugins` | Additional 3rd party RabbitMQ plugins to download and enable | `[]` |
159174

160175
### Metrics configuration
@@ -207,15 +222,15 @@ The following table lists the configurable parameters of the RabbitMQ chart and
207222

208223
### Security Context
209224

210-
| Parameter | Description | Default |
211-
| -------------------------------------------------------- | ------------------------------------------------- | --------- |
212-
| `podSecurityContext.fsGroup` | Group ID for the volumes of the pod | `999` |
213-
| `containerSecurityContext.allowPrivilegeEscalation` | Enable container privilege escalation | `false` |
214-
| `containerSecurityContext.runAsNonRoot` | Configure the container to run as a non-root user | `true` |
215-
| `containerSecurityContext.runAsUser` | User ID for the RabbitMQ container | `999` |
216-
| `containerSecurityContext.runAsGroup` | Group ID for the RabbitMQ container | `999` |
217-
| `containerSecurityContext.readOnlyRootFilesystem` | Mount container root filesystem as read-only | `true` |
218-
| `containerSecurityContext.capabilities.drop` | Linux capabilities to be dropped | `["ALL"]` |
225+
| Parameter | Description | Default |
226+
| --------------------------------------------------- | ------------------------------------------------- | --------- |
227+
| `podSecurityContext.fsGroup` | Group ID for the volumes of the pod | `999` |
228+
| `containerSecurityContext.allowPrivilegeEscalation` | Enable container privilege escalation | `false` |
229+
| `containerSecurityContext.runAsNonRoot` | Configure the container to run as a non-root user | `true` |
230+
| `containerSecurityContext.runAsUser` | User ID for the RabbitMQ container | `999` |
231+
| `containerSecurityContext.runAsGroup` | Group ID for the RabbitMQ container | `999` |
232+
| `containerSecurityContext.readOnlyRootFilesystem` | Mount container root filesystem as read-only | `true` |
233+
| `containerSecurityContext.capabilities.drop` | Linux capabilities to be dropped | `["ALL"]` |
219234

220235
### Liveness and readiness probes
221236

@@ -236,18 +251,18 @@ The following table lists the configurable parameters of the RabbitMQ chart and
236251

237252
### Additional Configuration
238253

239-
| Parameter | Description | Default |
240-
| ------------------- | ----------------------------------------------------------------------- | ------- |
241-
| `extraEnv` | Additional environment variables to set | `[]` |
242-
| `extraVolumes` | Additional volumes to add to the pod | `[]` |
243-
| `extraVolumeMounts` | Additional volume mounts to add to the RabbitMQ container | `[]` |
244-
| `extraObjects` | A list of additional Kubernetes objects to deploy alongside the release | `[]` |
245-
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
246-
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
247-
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
248-
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
249-
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
250-
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
254+
| Parameter | Description | Default |
255+
| --------------------- | ----------------------------------------------------------------------- | -------------- |
256+
| `extraEnv` | Additional environment variables to set | `[]` |
257+
| `extraVolumes` | Additional volumes to add to the pod | `[]` |
258+
| `extraVolumeMounts` | Additional volume mounts to add to the RabbitMQ container | `[]` |
259+
| `extraObjects` | A list of additional Kubernetes objects to deploy alongside the release | `[]` |
260+
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
261+
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
262+
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
263+
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
264+
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
265+
| `podManagementPolicy` | A list of additional Kubernetes objects to deploy alongside the release | `OrderedReady` |
251266

252267
### Persistent Volume Claim Retention Policy
253268

@@ -273,13 +288,13 @@ The following table lists the configurable parameters of the RabbitMQ chart and
273288
| `rbac.rules` | Custom RBAC rules | `[]` |
274289

275290
### Pod Disruption Budget configuration
291+
276292
| Parameter | Description | Default |
277293
| -------------------- | -------------------------------------------------------------- | ------- |
278294
| `pdb.create` | Enable/disable a Pod Disruption Budget creation | `false` |
279295
| `pdb.minAvailable` | Minimum number/percentage of pods that should remain scheduled | `""` |
280296
| `pdb.maxUnavailable` | Maximum number/percentage of pods that may be made unavailable | `""` |
281297

282-
283298
#### Extra Objects
284299

285300
You can use the `extraObjects` array to deploy additional Kubernetes resources (such as NetworkPolicies, ConfigMaps, etc.) alongside the release. This is useful for customizing your deployment with extra manifests that are not covered by the default chart options.
@@ -488,20 +503,17 @@ kubectl get secret my-rabbitmq -o jsonpath="{.data.password}" | base64 --decode
488503
### Common Issues
489504

490505
1. **Pod fails to start with permission errors**
491-
492506
- Ensure your storage class supports the required access modes
493507
- Check if security contexts are compatible with your cluster policies
494508
- Verify the RabbitMQ data directory permissions
495509

496510
2. **Cannot connect to RabbitMQ**
497-
498511
- Verify the service is running: `kubectl get svc`
499512
- Check if authentication is properly configured
500513
- Ensure firewall rules allow access to ports 5672 (AMQP) and 15672 (Management UI)
501514
- Check RabbitMQ logs: `kubectl logs <pod-name>`
502515

503516
3. **Clustering issues**
504-
505517
- Verify all nodes can reach each other
506518
- Check Erlang cookie consistency across cluster nodes
507519
- Ensure proper DNS resolution for pod hostnames

charts/rabbitmq/templates/configmap.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ data:
5959
prometheus.tcp.port = {{ .Values.metrics.port }}
6060
{{- end }}
6161
62+
{{- if .Values.definitions.enabled }}
63+
management.load_definitions = /etc/rabbitmq-definitions/defs.json
64+
{{- end }}
65+
6266
{{- if and .Values.config.extraConfiguration (ne .Values.config.extraConfiguration "") }}
6367
# Extra configuration
6468
{{ .Values.config.extraConfiguration | indent 4 }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- /*
2+
This file is rendered only if definitions are enabled AND an existing ConfigMap is NOT specified.
3+
It constructs a dictionary from the values and then converts it to a valid JSON object.
4+
*/}}
5+
{{- if and .Values.definitions.enabled (not .Values.definitions.existingConfigMap) }}
6+
{{- $def := dict }}
7+
{{- if .Values.definitions.users -}}{{- $_ := set $def "users" .Values.definitions.users }}{{- end }}
8+
{{- if .Values.definitions.vhosts -}}{{- $_ := set $def "vhosts" .Values.definitions.vhosts }}{{- end }}
9+
{{- if .Values.definitions.permissions -}}{{- $_ := set $def "permissions" .Values.definitions.permissions }}{{- end }}
10+
{{- if .Values.definitions.topic_permissions -}}{{- $_ := set $def "topic_permissions" .Values.definitions.topic_permissions }}{{- end }}
11+
{{- if .Values.definitions.parameters -}}{{- $_ := set $def "parameters" .Values.definitions.parameters }}{{- end }}
12+
{{- if .Values.definitions.global_parameters -}}{{- $_ := set $def "global_parameters" .Values.definitions.global_parameters }}{{- end }}
13+
{{- if .Values.definitions.policies -}}{{- $_ := set $def "policies" .Values.definitions.policies }}{{- end }}
14+
{{- if .Values.definitions.queues -}}{{- $_ := set $def "queues" .Values.definitions.queues }}{{- end }}
15+
{{- if .Values.definitions.exchanges -}}{{- $_ := set $def "exchanges" .Values.definitions.exchanges }}{{- end }}
16+
{{- if .Values.definitions.bindings -}}{{- $_ := set $def "bindings" .Values.definitions.bindings }}{{- end }}
17+
18+
apiVersion: v1
19+
kind: ConfigMap
20+
metadata:
21+
name: {{ include "rabbitmq.fullname" . }}-definitions
22+
namespace: {{ .Release.Namespace }}
23+
labels:
24+
{{- include "rabbitmq.labels" . | nindent 4 }}
25+
data:
26+
defs.json: |-
27+
{{- $def | toPrettyJson | nindent 4 }}
28+
{{- end }}

charts/rabbitmq/templates/statefulset.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ spec:
203203
- name: plugins
204204
mountPath: /opt/rabbitmq/plugins
205205
{{- end }}
206+
{{- if .Values.definitions.enabled }}
207+
- name: definitions
208+
mountPath: "/etc/rabbitmq-definitions/defs.json"
209+
subPath: {{ .Values.definitions.existingConfigMapKey | default "defs.json" }}
210+
{{- end }}
206211
{{- if .Values.extraVolumeMounts }}
207212
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
208213
{{- end }}
@@ -220,6 +225,11 @@ spec:
220225
- name: config
221226
configMap:
222227
name: {{ include "rabbitmq.fullname" . }}-config
228+
{{- if .Values.definitions.enabled }}
229+
- name: definitions
230+
configMap:
231+
name: {{ .Values.definitions.existingConfigMap | default (printf "%s-definitions" (include "rabbitmq.fullname" .)) }}
232+
{{- end }}
223233
{{- if .Values.extraVolumes }}
224234
{{- toYaml .Values.extraVolumes | nindent 8 }}
225235
{{- end }}
@@ -237,7 +247,7 @@ spec:
237247
{{- end }}
238248
{{- if .Values.persistence.enabled }}
239249
volumeClaimTemplates:
240-
- apiVersion: v1
250+
- apiVersion: v1
241251
kind: PersistentVolumeClaim
242252
metadata:
243253
name: data

charts/rabbitmq/values.schema.json

Lines changed: 92 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@
202202
"enum": ["absolute", "relative"]
203203
},
204204
"value": {
205-
"oneOf": [
206-
{"type": "string"},
207-
{"type": "number"}
208-
],
205+
"oneOf": [{ "type": "string" }, { "type": "number" }],
209206
"title": "Memory High Watermark Value",
210207
"description": "Memory high watermark value"
211208
}
@@ -357,7 +354,12 @@
357354
"description": "Persistent Volume access modes",
358355
"items": {
359356
"type": "string",
360-
"enum": ["ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany", "ReadWriteOncePod"]
357+
"enum": [
358+
"ReadWriteOnce",
359+
"ReadOnlyMany",
360+
"ReadWriteMany",
361+
"ReadWriteOncePod"
362+
]
361363
}
362364
},
363365
"size": {
@@ -456,10 +458,7 @@
456458
"description": "Resource limits for the container",
457459
"properties": {
458460
"cpu": {
459-
"oneOf": [
460-
{"type": "string"},
461-
{"type": "number"}
462-
],
461+
"oneOf": [{ "type": "string" }, { "type": "number" }],
463462
"title": "CPU Limit",
464463
"description": "CPU resource limit"
465464
},
@@ -476,10 +475,7 @@
476475
"description": "Resource requests for the container",
477476
"properties": {
478477
"cpu": {
479-
"oneOf": [
480-
{"type": "string"},
481-
{"type": "number"}
482-
],
478+
"oneOf": [{ "type": "string" }, { "type": "number" }],
483479
"title": "CPU Request",
484480
"description": "CPU resource request"
485481
},
@@ -790,6 +786,89 @@
790786
"type": "object",
791787
"description": "A Kubernetes manifest object. All fields are allowed."
792788
}
789+
},
790+
"definitions": {
791+
"type": "object",
792+
"title": "RabbitMQ Definitions",
793+
"description": "RabbitMQ definitions loaded on startup (https://www.rabbitmq.com/docs/definitions)",
794+
"properties": {
795+
"enabled": {
796+
"type": "boolean",
797+
"title": "Enable Definitions",
798+
"description": "Enable loading of RabbitMQ definitions on startup"
799+
},
800+
"existingConfigMap": {
801+
"type": "string",
802+
"title": "Existing ConfigMap",
803+
"description": "Name of existing ConfigMap containing RabbitMQ definitions"
804+
},
805+
"existingConfigMapKey": {
806+
"type": "string",
807+
"title": "Existing ConfigMap Key",
808+
"description": "Key in existing ConfigMap containing RabbitMQ definitions",
809+
"default": "defs.json"
810+
},
811+
"bindings": {
812+
"type": "array",
813+
"title": "Bindings",
814+
"description": "Array of RabbitMQ bindings to create",
815+
"items": { "type": "object" }
816+
},
817+
"global_parameters": {
818+
"type": "array",
819+
"title": "Global Parameters",
820+
"description": "Array of RabbitMQ global parameters to create",
821+
"items": { "type": "object" }
822+
},
823+
"parameters": {
824+
"type": "array",
825+
"title": "Parameters",
826+
"description": "Array of RabbitMQ parameters to create",
827+
"items": { "type": "object" }
828+
},
829+
"policies": {
830+
"type": "array",
831+
"title": "Policies",
832+
"description": "Array of RabbitMQ policies to create",
833+
"items": { "type": "object" }
834+
},
835+
"queues": {
836+
"type": "array",
837+
"title": "Queues",
838+
"description": "Array of RabbitMQ queues to create",
839+
"items": { "type": "object" }
840+
},
841+
"exchanges": {
842+
"type": "array",
843+
"title": "Exchanges",
844+
"description": "Array of RabbitMQ exchanges to create",
845+
"items": { "type": "object" }
846+
},
847+
"topic_permissions": {
848+
"type": "array",
849+
"title": "Topic Permissions",
850+
"description": "Array of RabbitMQ topic permissions to create",
851+
"items": { "type": "object" }
852+
},
853+
"users": {
854+
"type": "array",
855+
"title": "Users",
856+
"description": "Array of RabbitMQ users to create",
857+
"items": { "type": "object" }
858+
},
859+
"vhosts": {
860+
"type": "array",
861+
"title": "Virtual Hosts",
862+
"description": "Array of RabbitMQ vhosts to create",
863+
"items": { "type": "object" }
864+
},
865+
"permissions": {
866+
"type": "array",
867+
"title": "Permissions",
868+
"description": "Array of RabbitMQ permissions to set",
869+
"items": { "type": "object" }
870+
}
871+
}
793872
}
794873
}
795874
}

0 commit comments

Comments
 (0)