Create rabbitMQ Cluster
In this lab we will create a RabbitMQ Cluster using the quick start Rabbitmq Helm chart from the Catalog.
For this lab, RabbitMQ Operator needs to be activated.
Creating the RabbitMQ Cluster
-
In the left sidebar click on
Catalog
. -
Click on the
RabbitMQ
item in the Catalog. This will take you to the page with the readme where you can see all specifications and definitions that you can use to create your RabbitMQ Cluster with Queues and Policies. -
Click on the
Values
tab and fill in a name for the RabbitMQ Cluster. In this lab we will create a rabbitMQ Cluster with the namerabbit1
. -
Scroll down and optionally edit the cluster parameters.
-
Configure
Queues
andPolicies
for the rabbitMQ Cluster with 2queues
and 2policies
:
queues:
- name: my-quorum-queue1
spec:
durable: true
arguments:
x-queue-type: quorum
- name: my-quorum-queue2
spec:
arguments:
autoDelete: true
policies:
- name: my-policy1
pattern: ".*"
definition:
dead-letter-exchange: cc
ha-mode: all
spec:
applyTo: classic_queues
priority: 1
vhost: "/"
- name: my-policy2
pattern: ".*"
definition:
dead-letter-exchange: cc
max-age: 1h
spec:
applyTo: quorum_queues
Remember that even though these values can be edited afterwards, not all specifications or definitions can be updated after a queue
or policy
has been created. Please make sure everything is filled in correctly.
-
Click
submit
. -
Click
Deploy Changes
.
Accessing the RabbitMQ Management UI
To access the RabbitMQ Management UI
you have two options:
-
Retrieve the default user credentials and
port-forward
therabbitMQ server
-
Create a service to expose the
rabbitMQ server
and access theManagement UI
publicly. This is not recommended for production services
In this lab we are going to use port-forwarding.
In this example the rabbitMQ cluster
was created in the Team demo, so we have to get the secret
from the team-demo
namespace. Please retrieve the secret
from the namespace where the rabbitMQ cluster
was created.
- Use the following command to retrieve the username:
kubectl get secret rabbit1-rabbitmq-default-user -n team-demo -o jsonpath="{.data.username}" | base64 --decode
- Use the following command to retrieve the password:
kubectl get secret rabbit1-rabbitmq-default-user -n team-demo -o jsonpath="{.data.password}" | base64 --decode
Make sure you don't copy the %
symbol at the end.
Now you have to port-forward
the rabbitmq container
with port number 15672
that is inside the rabbitmq pod
called rabbit1-rabbitmq-server-0
to a port of your choice that is not used. In this lab we use port 56027
.
rabbit1-rabbitmq-server-0
has the prefix rabbit1
because this is the name that we gave the cluster.
- Use the following command to enable the port-forwarding:
kubectl port-forward -n team-demo rabbit1-rabbitmq-server-0 56027:15672
-
Open a browser and go to
http://localhost:56027
-
Use the previously acquired user credentials to log in. If you cannot log in, please check if the credentials are for the correct rabbitMQ cluster.
Checking the RabbitMQ Management UI
Now that we are logged in you should see the following:
We can also check the queues
that we specified when creating the rabbitmq cluster in the Queues and Streams
tab.
To see the policies
that we defined you can see them in the Admin
tab and under Policies
:
Connecting an Application to the rabbitMQ Cluster
To connect to the rabbitMQ cluster
you use AMQP
to open a connection. To open a connection you need to create a connection string using the username
, password
, host
and port
of the rabbitmq cluster.
- Get the host use the following command:
kubectl get secret rabbit1-rabbitmq-default-user -n team-demo -o jsonpath="{.data.host}" | base64 --decode
- Get the port use the following command:
kubectl get secret rabbit1-rabbitmq-default-user -n team-demo -o jsonpath="{.data.port}" | base64 --decode
The connection string is build like this:
amqp://USERNAME:PASSWORD@HOST:PORT/
With values:
amqp://default_user_mWPUECo5wsbtpgY3oze:MdzUL4CcgF-cQryLfk5uxqf57qqWBG8l@matthew-rabbit1-rabbitmq.team-admin.svc:5672/