Skip to content

Commit 6b82ce2

Browse files
committed
Update RabbitMQ and add configuration for Users and VHosts
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 9e33dc0 commit 6b82ce2

10 files changed

Lines changed: 3844 additions & 145 deletions

File tree

‎packages/apps/rabbitmq/Chart.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ type: application
1616
# This is the chart version. This version number should be incremented each time you make changes
1717
# to the chart and its templates, including the app version.
1818
# Versions are expected to follow Semantic Versioning (https://semver.org/)
19-
version: 0.3.0
19+
version: 0.4.0
2020

2121
# This is the version number of the application being deployed. This version number should be
2222
# incremented each time you make changes to the application. Versions are not expected to
2323
# follow Semantic Versioning. They should reflect the version the application is using.
2424
# It is recommended to use it with quotes.
25-
appVersion: "3.12.2"
25+
appVersion: "3.13.2"

‎packages/apps/rabbitmq/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ The service utilizes official RabbitMQ operator. This ensures the reliability an
1919
| `size` | Persistent Volume size | `10Gi` |
2020
| `replicas` | Number of RabbitMQ replicas | `3` |
2121
| `storageClass` | StorageClass used to store the data | `""` |
22+
23+
### Configuration parameters
24+
25+
| Name | Description | Value |
26+
| -------- | --------------------------- | ----- |
27+
| `users` | Users configuration | `{}` |
28+
| `vhosts` | Virtual Hosts configuration | `{}` |
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: {{ .Release.Name }}-dashboard-resources
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- secrets
10+
resourceNames:
11+
- {{ .Release.Name }}-default-user
12+
{{- range $name, $u := .Values.users }}
13+
- {{ $.Release.Name }}-{{ kebabcase $name }}-credentials
14+
{{- end }}
15+
verbs: ["get", "list", "watch"]
16+
- apiGroups:
17+
- ""
18+
resources:
19+
- services
20+
resourceNames:
21+
- {{ .Release.Name }}
22+
verbs: ["get", "list", "watch"]

‎packages/apps/rabbitmq/templates/rabbitmq.yaml‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,81 @@ spec:
1717
storageClassName: {{ . }}
1818
{{- end }}
1919
storage: {{ .Values.size }}
20+
21+
{{- range $user, $u := .Values.users }}
22+
23+
{{- $password := $u.password }}
24+
{{- if not $password }}
25+
{{- with (dig "data" "password" "" (lookup "v1" "Secret" $.Release.Namespace (printf "%s-%s-credentials" $.Release.Name (kebabcase $user)))) }}
26+
{{- $password = b64dec . }}
27+
{{- end }}
28+
{{- end }}
29+
{{- if not $password }}
30+
{{- $password = (randAlphaNum 16) }}
31+
{{- end }}
32+
33+
---
34+
apiVersion: rabbitmq.com/v1beta1
35+
kind: User
36+
metadata:
37+
name: {{ $.Release.Name }}-{{ kebabcase $user }}
38+
annotations:
39+
config: '{{ printf "%s %s" $user $password | sha256sum }}'
40+
spec:
41+
importCredentialsSecret:
42+
name: {{ $.Release.Name }}-{{ $user }}-credentials
43+
rabbitmqClusterReference:
44+
name: {{ $.Release.Name }}
45+
---
46+
apiVersion: v1
47+
kind: Secret
48+
metadata:
49+
name: {{ $.Release.Name }}-{{ kebabcase $user }}-credentials
50+
type: Opaque
51+
stringData:
52+
username: {{ $user }}
53+
password: {{ $password }}
54+
{{- end }}
55+
56+
{{- range $host, $h := .Values.vhosts }}
57+
---
58+
apiVersion: rabbitmq.com/v1beta1
59+
kind: Vhost
60+
metadata:
61+
name: {{ $.Release.Name }}-{{ kebabcase $host }}
62+
spec:
63+
name: {{ $host }}
64+
rabbitmqClusterReference:
65+
name: {{ $.Release.Name }}
66+
{{- range $user := $h.roles.admin }}
67+
---
68+
apiVersion: rabbitmq.com/v1beta1
69+
kind: Permission
70+
metadata:
71+
name: {{ $.Release.Name }}-{{ kebabcase $host }}-{{ kebabcase $user }}
72+
spec:
73+
vhost: "{{ $host }}"
74+
user: "{{ $user }}"
75+
permissions:
76+
write: ".*"
77+
configure: ".*"
78+
read: ".*"
79+
rabbitmqClusterReference:
80+
name: {{ $.Release.Name }}
81+
{{- end }}
82+
{{- range $user := $h.roles.readonly }}
83+
---
84+
apiVersion: rabbitmq.com/v1beta1
85+
kind: Permission
86+
metadata:
87+
name: {{ $.Release.Name }}-{{ kebabcase $host }}-{{ kebabcase $user }}
88+
spec:
89+
vhost: "{{ $host }}"
90+
user: "{{ $user }}"
91+
permissions:
92+
read: ".*"
93+
rabbitmqClusterReference:
94+
name: {{ $.Release.Name }}
95+
{{- end }}
96+
97+
{{- end }}

‎packages/apps/rabbitmq/values.schema.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
"type": "string",
2222
"description": "StorageClass used to store the data",
2323
"default": ""
24+
},
25+
"vhosts": {
26+
"type": "object",
27+
"description": "Virtual Hosts configuration",
28+
"default": {}
2429
}
2530
}
2631
}

‎packages/apps/rabbitmq/values.yaml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,33 @@ external: false
99
size: 10Gi
1010
replicas: 3
1111
storageClass: ""
12+
13+
## @section Configuration parameters
14+
15+
## @param users [object] Users configuration
16+
## Example:
17+
## users:
18+
## user1:
19+
## password: strongpassword
20+
## user2:
21+
## password: hackme
22+
## user3:
23+
## password: testtest
24+
##
25+
users: {}
26+
27+
## @param vhosts Virtual Hosts configuration
28+
## Example:
29+
## vhosts:
30+
## myapp:
31+
## roles:
32+
## admin:
33+
## - user1
34+
## - user2
35+
## readonly:
36+
## - user3
37+
## test:
38+
## roles:
39+
## admin:
40+
## - user3
41+
vhosts: {}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## @section Common parameters
2+
3+
## @param external Enable external access from outside the cluster
4+
## @param size Persistent Volume size
5+
## @param replicas Number of RabbitMQ replicas
6+
## @param storageClass StorageClass used to store the data
7+
##
8+
external: false
9+
size: 10Gi
10+
replicas: 3
11+
storageClass: ""
12+
13+
## @section Configuration parameters
14+
15+
users:
16+
user1:
17+
password: strongpassword
18+
user2:
19+
password: hackme
20+
user4:
21+
password: testtest
22+
user5: {}
23+
user6: {}
24+
25+
26+
vhosts:
27+
myapp:
28+
roles:
29+
admin:
30+
- user1
31+
- user2
32+
readonly:
33+
- user4
34+
test:
35+
roles:
36+
admin:
37+
- user4

‎packages/system/rabbitmq-operator/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ update:
88
wget -O templates/cluster-operator.yml https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml
99
yq -i 'del(select(.kind=="Namespace"))' templates/cluster-operator.yml
1010
sed -i 's/rabbitmq-system/$(NAMESPACE)/g' templates/cluster-operator.yml
11+
wget -O templates/messaging-topology-operator.yml https://github.com/rabbitmq/messaging-topology-operator/releases/latest/download/messaging-topology-operator-with-certmanager.yaml
12+
yq -i 'del(select(.kind=="Namespace"))' templates/messaging-topology-operator.yml
13+
sed -i 's/rabbitmq-system/$(NAMESPACE)/g' templates/messaging-topology-operator.yml

0 commit comments

Comments
 (0)