Skip to content

Commit af00fe0

Browse files
bl4kozOnlyKroks
andauthored
[rabbitmq] add traffic distribution and option to source definitions from existingSecret (CloudPirates-io#334)
* [rabbitmq]: add missing readme heading for definitions section * [rabbitmq]: add trafficDistribution and topology spread constraint options * [rabbitmq]: fix duplicate work * [rabbitmq]: also add support for sourcing definitions from secret * [rabbitmq]: add missing stuff --------- Co-authored-by: Finn Rades <64548817+zOnlyKroks@users.noreply.github.com>
1 parent 36ca7c7 commit af00fe0

File tree

6 files changed

+58
-21
lines changed

6 files changed

+58
-21
lines changed

charts/rabbitmq/README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,15 @@ The following table lists the configurable parameters of the RabbitMQ chart and
103103
| `podAnnotations` | Annotations to attach to pods | `{}` |
104104
| `statefulsetAnnotations` | Annotations for StatefulSet | `{}` |
105105

106+
### RabbitMQ Definitions
107+
106108
| Parameter | Description | Default |
107109
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
108110
| `definitions.enabled` | Enable loading of RabbitMQ definitions on startup. When `true`, definitions will be loaded at container boot. | `false` |
109111
| `definitions.existingConfigMap` | Name of an existing ConfigMap containing RabbitMQ definitions (e.g., created via `kubectl create configmap rmq-defs --from-file=defs.json`). | `""` |
110112
| `definitions.existingConfigMapKey` | Key in the existing ConfigMap containing the RabbitMQ definitions JSON file. | `defs.json` |
113+
| `defintions.existingSecret` | Name of an existing Secret containing RabbitMQ definitions. | `""` |
114+
| `definitions.existingSecretKey` | Key in the existing Secret containing the RabbitMQ definitions JSON file. | `defs.json` |
111115
| `definitions.users` | Array of RabbitMQ users to create. | `[]` |
112116
| `definitions.vhosts` | Array of RabbitMQ virtual hosts to create. | `[]` |
113117
| `definitions.permissions` | Array of RabbitMQ permissions to set per vhost. | `[]` |
@@ -121,15 +125,16 @@ The following table lists the configurable parameters of the RabbitMQ chart and
121125

122126
### Service configuration
123127

124-
| Parameter | Description | Default |
125-
| ----------------------------- | -------------------------------------- | ----------- |
126-
| `service.type` | Kubernetes service type | `ClusterIP` |
127-
| `service.amqpPort` | RabbitMQ AMQP service port | `5672` |
128-
| `service.managementPort` | RabbitMQ management UI port | `15672` |
129-
| `service.epmdPort` | RabbitMQ EPMD port | `4369` |
130-
| `service.distPort` | RabbitMQ distribution port | `25672` |
131-
| `service.annotations` | Kubernetes service annotations | `{}` |
132-
| `service.annotationsHeadless` | Kubernetes service annotationsHeadless | `25672` |
128+
| Parameter | Description | Default |
129+
| ----------------------------- | ------------------------------------------- | ----------- |
130+
| `service.type` | Kubernetes service type | `ClusterIP` |
131+
| `service.amqpPort` | RabbitMQ AMQP service port | `5672` |
132+
| `service.managementPort` | RabbitMQ management UI port | `15672` |
133+
| `service.epmdPort` | RabbitMQ EPMD port | `4369` |
134+
| `service.distPort` | RabbitMQ distribution port | `25672` |
135+
| `service.annotations` | Kubernetes service annotations | `{}` |
136+
| `service.annotationsHeadless` | Kubernetes service annotationsHeadless | `25672` |
137+
| `service.trafficDistribution` | Traffic distribution policy for the service | `""` |
133138

134139
### RabbitMQ Authentication
135140

charts/rabbitmq/templates/definitions-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This file is rendered only if definitions are enabled AND an existing ConfigMap is NOT specified.
33
It constructs a dictionary from the values and then converts it to a valid JSON object.
44
*/}}
5-
{{- if and .Values.definitions.enabled (not .Values.definitions.existingConfigMap) }}
5+
{{- if and .Values.definitions.enabled (not .Values.definitions.existingConfigMap) (not .Values.definitions.existingSecret) }}
66
{{- $def := dict }}
77
{{- if .Values.definitions.users -}}{{- $_ := set $def "users" .Values.definitions.users }}{{- end }}
88
{{- if .Values.definitions.vhosts -}}{{- $_ := set $def "vhosts" .Values.definitions.vhosts }}{{- end }}

charts/rabbitmq/templates/service.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ metadata:
1111
{{- end }}
1212
spec:
1313
type: {{ .Values.service.type }}
14+
trafficDistribution: {{ .Values.service.trafficDistribution }}
1415
ports:
1516
- port: {{ .Values.service.amqpPort }}
1617
targetPort: amqp
@@ -31,4 +32,4 @@ spec:
3132
name: {{ .name }}
3233
{{- end }}
3334
selector:
34-
{{- include "rabbitmq.selectorLabels" . | nindent 4 }}
35+
{{- include "rabbitmq.selectorLabels" . | nindent 4 }}

charts/rabbitmq/templates/statefulset.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,13 @@ spec:
210210
{{- if .Values.definitions.enabled }}
211211
- name: definitions
212212
mountPath: "/etc/rabbitmq-definitions/defs.json"
213-
subPath: {{ .Values.definitions.existingConfigMapKey | default "defs.json" }}
213+
subPath: {{- if .Values.definitions.existingConfigMap }}
214+
{{ .Values.definitions.existingConfigMapKey | default "defs.json" }}
215+
{{- else if .Values.definitions.existingSecret }}
216+
{{ .Values.definitions.existingSecretKey | default "defs.json" }}
217+
{{- else }}
218+
defs.json
219+
{{- end }}
214220
{{- end }}
215221
{{- if .Values.extraVolumeMounts }}
216222
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
@@ -231,8 +237,16 @@ spec:
231237
name: {{ include "rabbitmq.fullname" . }}-config
232238
{{- if .Values.definitions.enabled }}
233239
- name: definitions
240+
{{- if .Values.definitions.existingConfigMap }}
234241
configMap:
235-
name: {{ .Values.definitions.existingConfigMap | default (printf "%s-definitions" (include "rabbitmq.fullname" .)) }}
242+
name: {{ .Values.definitions.existingConfigMap }}
243+
{{- else if .Values.definitions.existingSecret }}
244+
secret:
245+
secretName: {{ .Values.definitions.existingSecret }}
246+
{{- else }}
247+
configMap:
248+
name: {{ printf "%s-definitions" (include "rabbitmq.fullname" .) }}
249+
{{- end }}
236250
{{- end }}
237251
{{- if .Values.extraVolumes }}
238252
{{- toYaml .Values.extraVolumes | nindent 8 }}

charts/rabbitmq/values.schema.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@
108108
"description": "Kubernetes service type",
109109
"enum": ["ClusterIP", "NodePort", "LoadBalancer", "ExternalName"]
110110
},
111+
"trafficDistribution": {
112+
"type": "string",
113+
"description": "Traffic distribution policy",
114+
"enum": ["", "PreferClose", "PreferSameZone", "PreferSameNode"],
115+
"default": ""
116+
},
111117
"amqpPort": {
112118
"type": "integer",
113119
"title": "AMQP Port",
@@ -913,18 +919,12 @@
913919
"description": "Enable/disable a Pod Disruption Budget creation"
914920
},
915921
"minAvailable": {
916-
"oneOf": [
917-
{"type": "string"},
918-
{"type": "integer"}
919-
],
922+
"oneOf": [{ "type": "string" }, { "type": "integer" }],
920923
"title": "Min Available",
921924
"description": "Minimum number/percentage of pods that should remain scheduled"
922925
},
923926
"maxUnavailable": {
924-
"oneOf": [
925-
{"type": "string"},
926-
{"type": "integer"}
927-
],
927+
"oneOf": [{ "type": "string" }, { "type": "integer" }],
928928
"title": "Max Unavailable",
929929
"description": "Maximum number/percentage of pods that may be made unavailable"
930930
}
@@ -951,6 +951,17 @@
951951
"description": "Key in existing ConfigMap containing RabbitMQ definitions",
952952
"default": "defs.json"
953953
},
954+
"existingSecret": {
955+
"type": "string",
956+
"title": "Existing Secret",
957+
"description": "Name of existing Secret containing RabbitMQ definitions"
958+
},
959+
"existingSecretKey": {
960+
"type": "string",
961+
"title": "Existing Secret Key",
962+
"description": "Key in existing Secret containing RabbitMQ definitions",
963+
"default": "defs.json"
964+
},
954965
"bindings": {
955966
"type": "array",
956967
"title": "Bindings",

charts/rabbitmq/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ replicaCount: 1
3838
service:
3939
## @param service.type Kubernetes service type
4040
type: ClusterIP
41+
## @param service.trafficDistribution Traffic distribution policy for the service
42+
trafficDistribution: ""
4143
## @param service.amqpPort RabbitMQ AMQP service port
4244
amqpPort: 5672
4345
## @param service.managementPort RabbitMQ management UI port
@@ -374,6 +376,10 @@ definitions:
374376
existingConfigMap: ""
375377
## @param definitions.existingConfigMapKey Key in existing ConfigMap containing RabbitMQ definitions
376378
existingConfigMapKey: defs.json
379+
## @param definitions.existingSecret Name of existing Secret containing RabbitMQ definitions
380+
existingSecret: ""
381+
## @param definitions.existingSecretKey Key in existing Secret containing RabbitMQ definitions
382+
existingSecretKey: defs.json
377383
## @param definitions.bindings Array of RabbitMQ bindings to create
378384
bindings: []
379385
## @param definitions.global_parameters Array of RabbitMQ global parameters to create

0 commit comments

Comments
 (0)