How Can We Install One RabbitMQ Instance On Kubernetes Cluster

tarafından
1067
How Can We Install One RabbitMQ Instance On Kubernetes Cluster

I will explain the “how can we install the RabbitMQ instance on kubernetes cluster” ın this topic.

Step1:
Create new namespace on your cluster.

kubectl create ns rabbitmq


Step2:
Create new deployment file like below. We will use the below image that has a management console ui.

vim rabbitmq.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: rabbitmq
  name: rabbitmq
  labels:
    app: rabbitmq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
      - name: rabbitmq
        image: rabbitmq:3-management
        ports:
        - name: internal
          containerPort: 5672
        - name: management
          containerPort: 15672
kubectl apply -f rabbitmq.yaml


Step3:

Create new service yaml file to access the management console and internal communication port.

vim rabbitmqsvc.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: rabbitmq
  name: rabbitmq
  labels:
    app: rabbitmq
spec:
  ports:
  - port: 5672
    protocol: TCP
    name: internal
  - port: 15672
    protocol: TCP
    name: management
  selector:
    app: rabbitmq
  type: NodePort
kubectl apply -f rabbitmqsvc.yaml

Step4:
Create new ingress to access the management ui.

vim ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rabbitmqing
  namespace: rabbitmq
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: rabbitmq
            port:
              number: 15672
    host: rabbitmq.172.17.135.224.nip.io
kubectl apply -f ingress.yaml

Step5:
You can login the rabbitmq ui with default username and password.(guest:guest)

That’s it. Have happy days.!!! 🙂