File tree Expand file tree Collapse file tree 6 files changed +134
-0
lines changed
docs/examples/import-multiple-definition-files Expand file tree Collapse file tree 6 files changed +134
-0
lines changed Original file line number Diff line number Diff line change 1+ # Import Multiple Definition Files Example
2+
3+ RabbitMQ supports importing definitions from a folder with multiple JSON files.
4+ In this example we take advantage of this feature to split the definitions into a ConfigMap
5+ with most of the definitions and a Secret that contains user definitions only.
6+
7+ First, we need to create the ConfigMap and Secret with the definitions:
8+ ``` bash
9+ kubectl create configmap definitions --from-file=' definitions.json=/my/path/to/definitions.json'
10+ kubectl create secret generic users --from-file=' definitions.json=/my/path/to/users.json'
11+ ```
12+
13+ Afterwards, we leverage the StatefulSet Override to mount these resources as files in a folder
14+ and specify that folder as the defintion import path.
Original file line number Diff line number Diff line change 1+ {
2+ "permissions" : [
3+ {
4+ "configure" : " .*" ,
5+ "read" : " .*" ,
6+ "user" : " guest" ,
7+ "vhost" : " /" ,
8+ "write" : " .*"
9+ }
10+ ],
11+ "bindings" : [
12+ {
13+ "arguments" : {},
14+ "destination" : " qq" ,
15+ "destination_type" : " queue" ,
16+ "routing_key" : " 3c01b232-e21a-4320-bbdb-329eede5188c" ,
17+ "source" : " direct" ,
18+ "vhost" : " /"
19+ }
20+ ],
21+ "queues" : [
22+ {
23+ "arguments" : {
24+ "x-queue-type" : " quorum"
25+ },
26+ "auto_delete" : false ,
27+ "durable" : true ,
28+ "name" : " qq" ,
29+ "type" : " quorum" ,
30+ "vhost" : " /"
31+ }
32+ ],
33+ "parameters" : [],
34+ "policies" : [],
35+ "rabbitmq_version" : " 4.1.0+beta.3.47.gac7dcc9" ,
36+ "rabbit_version" : " 4.1.0+beta.3.47.gac7dcc9" ,
37+ "exchanges" : [
38+ {
39+ "arguments" : {},
40+ "auto_delete" : false ,
41+ "durable" : true ,
42+ "name" : " direct" ,
43+ "type" : " direct" ,
44+ "vhost" : " /"
45+ }
46+ ],
47+ "vhosts" : [
48+ {
49+ "default_queue_type" : " classic" ,
50+ "limits" : [],
51+ "metadata" : {
52+ "description" : " Default virtual host" ,
53+ "tags" : []
54+ },
55+ "name" : " /"
56+ }
57+ ],
58+ "global_parameters" : [
59+ {
60+ "name" : " cluster_tags" ,
61+ "value" : []
62+ }
63+ ],
64+ "topic_permissions" : []
65+ }
Original file line number Diff line number Diff line change 1+ apiVersion : rabbitmq.com/v1beta1
2+ kind : RabbitmqCluster
3+ metadata :
4+ name : import-multiple-definition-files
5+ spec :
6+ replicas : 1
7+ override :
8+ statefulSet :
9+ spec :
10+ template :
11+ spec :
12+ containers :
13+ - name : rabbitmq
14+ volumeMounts :
15+ # 01- prefix is used to ensure that users are imported first
16+ - mountPath : /etc/rabbitmq/definitions/01-users.json
17+ name : users
18+ subPath : users.json
19+ # 02- prefix is used to ensure that definitions are imported after users, since
20+ # they might reference users (eg. to set up permissions)
21+ - mountPath : /etc/rabbitmq/definitions/02-definitions.json
22+ name : definitions
23+ subPath : definitions.json
24+ volumes :
25+ - name : users
26+ secret :
27+ secretName : users # Name of the Secret containing user definitions
28+ - name : definitions
29+ configMap :
30+ name : definitions # Name of the ConfigMap containing other definitions
31+ rabbitmq :
32+ additionalConfig : |
33+ load_definitions = /etc/rabbitmq/definitions # Path to the folder
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ kubectl create configmap definitions --from-file=definitions.json
4+ kubectl create secret generic users --from-file=users.json
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -x
4+
5+ kubectl exec import-multiple-definition-files-server-0 -c rabbitmq -- rabbitmqctl authenticate_user guest guest
Original file line number Diff line number Diff line change 1+ {
2+ "users" : [
3+ {
4+ "hashing_algorithm" : " rabbit_password_hashing_sha256" ,
5+ "limits" : {},
6+ "name" : " guest" ,
7+ "password_hash" : " KYBvEg5fU0m1sE8E6qNmjITswwixc9EMjxWcjiC5f/70vgmC" ,
8+ "tags" : [
9+ " administrator"
10+ ]
11+ }
12+ ]
13+ }
You can’t perform that action at this time.
0 commit comments