image image
Knowledge-Base-Hero-Background

Welcome to Xelon Knowledge Base

<learn> use </share>

image image

How to: Deploy RabbitMQ on Kubernetes Cluster

image

RabbitMQ is a general-purpose, established message broker. It facilitates the exchange of messages between sets of microservices and allows them to communicate reliably and efficiently between each set. Kubernetes on the other hand is an ideal operator when it comes to the deployment of a RabbitMQ cluster.

Kubernetes is an orchestration cluster platform that is used for the automatic deployment process of nodes. The automated container and scaling capabilities of Kubernetes enhance the deployment of RabbitMQ’s dependability in the Xelon HQ by extending its cluster environment.

To configure the RMQ cluster we use the platform Xelon HQ, we need to create an environment onto which the RMQ systems files will execute. To achieve this, we need to use the msiexec.exe system command to activate the environment.

Prerequisites

For the installation and deployment, you need to:

  • Have a Kubernetes cluster. Here is our cluster:
apiVersion: v1
kind: Config
clusters:
- name: "k8s-technical-writer-cluster"
cluster:
server: "https://explicitip/k8s/clusters/c-6n7xc"
  • Have access to a Windows terminal (Command Prompt(CMD))
  • Install the kubectl tool.

Setting up RabbitMQ

After installing the RabbitMQ .exe, you need to install the necessary.YAML files on the server and router as
follows:

https://explicitip/k8s/clusters/c-6n7xc

09_Deploy RabbitMQ_01

Deploying RabbitMQ on Kubernetes

To deploy RabbitMQ instance on Kubernetes, you need to use a Stateful Set. The Stateful Set ensures that the RabbitMQ directories are deployed in a systematic order/ the Stateful State helps to avoid peer discovery race conditions while deploying multiple RabbitMQ clusters.

To deploy RMQ cluster you need to create the following:

  • Kind: RabbitMQ Cluster

This is the RabbitMQ file directory which is installed by the RabbitMQ cluster operator which we just installed.

  • Metadata name

The metadata name is the name that we will assign to our rabbit cluster on Xelon HQ Kubernetes.

Spec replicas

The spec replica is the number of Rabbit MQ replicas that will be created during the deployment of the RabbitMQ Cluster.

Resources limits

These are the limits to which a single RMQ can go. To check more of RabbitMQ resources limit, please check the following link: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

RabbitMQ additional config files

The designated cluster is not enough to deploy on a Kubernetes cluster hence you need additional config files. Please obtain the additional RabbitMQ clusters here: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

Service type

The service type file is a Kubernetes service that is used to expose the Rabbit MQ cluster when deployment is done. Now let’s take a look at the RMQ cluster. To check the RMQ cluster, simply type the following command:

$ kubectl describe RabbitmqCluster production-rabbitmqcluster

In the above cluster, we have specified the default password and username which will be used as a guest. Additionally, the command creates a K8s secret cluster which will later help us retrieve and extract both the username and password.

For username:

$ kubectl get secret production-rabbitmqcluster-default-user -o jsonpath='{.data.username}' | base64 –decode

For password:

$ kubectl get secret production-rabbitmqcluster-default-user -o jsonpath='{.data.password}' | base64 –decode

After initiating the cluster, expose the RabbitMQ Cluster by typing the following command:

$ kubectl get all -l app.kubernetes.io/part-of=rabbitmq

When you run the above command you should see a Stateful Set, headless service, and Kubernetes load balancer.

Now it is time to deploy and check you assigned cluster:

apiVersion: apps/v1
kind: volumeClaimTemplates:
- metadata:
name: rabbitmq-data
namespace: test-rabbitmq
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "3Gi"
template:
metadata:
name: rabbitmq
namespace: test-rabbitmq
labels:
app: rabbitmq
Now to deploy the above cluster in the Xelon HQ, insert the provided cluster and merge
with the above cluster to give:
apiVersion: v1
kind: Config
clusters:
- name: "k8s-technical-writer-cluster"
cluster:
server: "https://explicitip/k8s/clusters/c-6n7xc"
certificate-authority-data:
"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJpVENDQ\
VM2Z0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQTdNUnd3R2dZRFZRUUtFeE5rZV
c1aGJXbGoKY\
kdsemRHVnVaWEl0YjNKbk1Sc3dHUVlEVlFRREV4SmtlVzVoYldsamJHbHpkR1Z1Wl
hJdFkyRXdIa\
GNOTWpFdwpOVEUwTURreE5qSTBXaGNOTXpFd05URXlNRGt4TmpJMFdqQTdNUnd3R2
dZRFZRUUtFe\
E5rZVc1aGJXbGpiR2x6CmRHVnVaWEl0YjNKbk1Sc3dHUVlEVlFRREV4SmtlVzVoYl
dsamJHbHpkR\
1Z1WlhJdFkyRXdXVEFUQmdjcWhrak8KUFFJQkJnZ3Foa2pPUFFNQkJ3TkNBQVFYVl
k0eGVNNEtkc\
nQyNzhwclNRMTdKK3hhRnlQaEdPeUVaOUsvYzZpUApJSFRCN2tINSt3eWNEVjhHaW
xxd0VYS3FkN\
WFvOVkrRElCQzNleTBTUVg5Rm95TXdJVEFPQmdOVkhROEJBZjhFCkJBTUNBcVF3RH
dZRFZSMFRBU\
UgvQkFVd0F3RUIvekFLQmdncWhrak9QUVFEQWdOSkFEQkdBaUVBMWtCTjlrNEgKYz
lpSXNrMVMyV\
3plQlhTNkRFWE9xKzJORWpFZnpCaG1EbUVDSVFDRHRYbUZrbG1oL2tENXAxL1A2OG
hPdW5EUwo1e\
Xl0T2NvU25oQXVYaUE3enc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t"
volumeClaimTemplates:
- metadata:
name: rabbitmq-data
namespace: test-rabbitmq
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "3Gi"
template:
metadata:
name: rabbitmq
namespace: test-rabbitmq
labels:
app: rabbitmq
users:
- name: "k8s-technical-writer-cluster"
user:
token: "kubeconfig-user-
hvpzh:r57s2f6sqlqfmkmxmxmfznhqq5w5kfbvzns6z5fpns5rfdhfhllwn2"
contexts:
- name: "k8s-technical-writer-cluster"
context:
user: "k8s-technical-writer-cluster"
cluster: "k8s-technical-writer-cluster"
current-context: "k8s-technical-writer-cluster"

RabbitMQ Cluster Management

Now that we have displayed the RMQ cluster, we need to check the RMQ cluster aspect. For this you need to activate the StorageClass by typing the following command:

users:
- name: "k8s-technical-writer-cluster"
user:
token: "kubeconfig-user-
hvpzh:r57s2f6sqlqfmkmxmxmfznhqq5w5kfbvzns6z5fpns5rfdhfhllwn2"

After this check the node deployed in the cluster by typing:

09_Deploy RabbitMQ_02

Now that you have checked and verified the cluster,  create and mount the service as an environment variable to the Xelon HQ pod. Activate it by typing the following command:

name: "k8s-technical-writer-cluster"
context:
user: "k8s-technical-writer-cluster"
cluster: "k8s-technical-writer-cluster"
current-context: "k8s-technical-writer-cluster"

Running RabbitMQ

Navigate to the rabbitmq cluster ad run the below cluster to deploy in the Xelon HQ.

users:
- name: "k8s-technical-writer-cluster"
user:
token: "kubeconfig-user-
hvpzh:r57s2f6sqlqfmkmxmxmfznhqq5w5kfbvzns6z5fpns5rfdhfhllwn2"
contexts:
- name: "k8s-technical-writer-cluster"
context:
user: "k8s-technical-writer-cluster"
cluster: "k8s-technical-writer-cluster"
current-context: "k8s-technical-writer-cluster"

Exiting RabbitMQ cluster

Return the KUBECONFIG environment variable to its original value. For this, you need to type the following command to initiate the restoration process of the cluster:

$Env:KUBECONFIG=$ENV:KUBECONFIG_SAVED

If you have any questions how to use Rabbit MQ in the Xelon HQ please feel free to contact our support team!

 

What are your Feelings:

  • smiley
  • smiley
  • smiley

Leave a Reply

Your email address will not be published. Required fields are marked *