Skip to content
Merged
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
27 changes: 27 additions & 0 deletions docs/examples/topic-exchanges/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Topic Exchange Example

In this example, we will create two topic exchanges, and a user that have read and write access to them in the default `/` vhost.

Before creating any topology objects with Messaging Topology Operator, please deploy a RabbitmqCluster named `test`, or any name you see fit. You will need to modify the example manifests if the RabbitmqCluster name is something other than `test`.

After the RabbitMQ cluster is successfully created, you can first create the two topic exchanges and a user by:

```bash
kubectl apply -f topic-exchanges.yaml # create topic exchanges `topic-a` and `topic-b` in default vhost `/`
kubectl apply -f user.yaml # create user `example`
```

Then you can grant user `example` permissions to both topic exchanges by:

```bash
kubectl apply -f user-topic-permissions.yaml
```

This will create two `topicpermissions.rabbitmq.com` objects: one for managing user `example` permissions to `topic-a` and the other one manages user `example` permissions to `topic-b`.

To clean up, you can run:

```bash
kubectl delete -f user-topic-permissions.yaml -f user.yaml -f topic-exchanges.yaml
```

25 changes: 25 additions & 0 deletions docs/examples/topic-exchanges/topic-exchanges.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# More on topic exchange and other exchange types, see: https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchange-topic.
---
apiVersion: rabbitmq.com/v1beta1
kind: Exchange
metadata:
name: some-topic
spec:
name: topic-a # name of the exchange
type: topic # default to 'direct' if not provided
autoDelete: false
durable: true
rabbitmqClusterReference:
name: test # rabbitmqCluster must exist in the same namespace as this resource
---
apiVersion: rabbitmq.com/v1beta1
kind: Exchange
metadata:
name: another-topic
spec:
name: topic-b # name of the exchange
type: topic # default to 'direct' if not provided
autoDelete: false
durable: true
rabbitmqClusterReference:
name: test # rabbitmqCluster must exist in the same namespace as this resource
29 changes: 29 additions & 0 deletions docs/examples/topic-exchanges/user-topic-permissions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
apiVersion: rabbitmq.com/v1beta1
kind: TopicPermission
metadata:
name: permission-example-a
spec:
vhost: "/" # name of a vhost; required
userReference:
name: "topic-exchange-example" # name of a user.rabbitmq.com in the same namespace; must specify either spec.userReference or spec.user
permissions:
exchange: "topic-a"
write: ".*"
read: ".*"
rabbitmqClusterReference:
name: test
---
apiVersion: rabbitmq.com/v1beta1
kind: TopicPermission
metadata:
name: permission-example-b
spec:
vhost: "/" # name of a vhost; required
user: "example"
permissions:
exchange: "topic-b"
write: ".*"
read: ".*"
rabbitmqClusterReference:
name: test
18 changes: 18 additions & 0 deletions docs/examples/topic-exchanges/user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Secret
metadata:
name: credentials-secret
type: Opaque
stringData:
username: example
password: whyareyoulookinghere
---
apiVersion: rabbitmq.com/v1beta1
kind: User
metadata:
name: topic-exchange-example
spec:
rabbitmqClusterReference:
name: test # rabbitmqCluster must exist in the same namespace as this resource
importCredentialsSecret:
name: credentials-secret