Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rabbit-mq deployment with kubernetes

I'm in a progress to migrate to kuberenetes from docker-compose. One of the services we're using is rabbit-mq. When I try to deploy rabbit-mq 3.6.16-management I receive the error:

/usr/local/bin/docker-entrypoint.sh: line 382: /etc/rabbitmq/rabbitmq.config: Permission denied.

While it works in docker-compose deployment.

Kuberentes:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: rabbit-mq
  name: rabbit-mq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbit-mq
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
         app: rabbit-mq
    spec:
      containers:
      - image: rabbitmq:3.6.16-management
        name: rabbit-mq
        ports:
        - containerPort: 15671
        - containerPort: 5671
        volumeMounts:
        - mountPath: /etc/rabbitmq
          name: rabbit-mq-data
      restartPolicy: Always
      hostname: rabbit-mq
      volumes:
      - name: rabbit-mq-data
        persistentVolumeClaim:
          claimName: rabbit-mq-data

PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: rabbit-mq-data
  name: rabbit-mq-data
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 16Gi

PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: rabbit-mq-data
  labels:
    type: local
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 16Gi
  hostPath:
    path: "/etc/rabbitmq"

Docker-Compose:

  rabbit-mq:
      image: rabbitmq:3.6.16-management
      ports:
        - "15671:15671"
        - "5671:5671"
      container_name: rabbit-mq
      volumes:
        - rabbit-mq-data:/etc/rabbitmq
      restart: on-failure:5
like image 562
Oren Ashkenazy Avatar asked Aug 29 '18 15:08

Oren Ashkenazy


People also ask

Does RabbitMQ support clustering?

RabbitMQ supports: clustering of multiple nodes. synchronous replication - replicated queues. asynchronous cluster-to-cluster message routing - exchange federation and shovels.

Is RabbitMQ stateful?

RabbitMQ requires using a Stateful Set to deploy a RabbitMQ cluster to Kubernetes. The Stateful Set ensures that the RabbitMQ nodes are deployed in order, one at a time.


1 Answers

Eventually I've used configmap and secrets to mount files instead of PV and works as expected.

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: rabbit-mq
  name: rabbit-mq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbit-mq
  template:
    metadata:
      labels:
         app: rabbit-mq
    spec:
      containers:
      - image: rabbitmq:3.6.16-management
        name: rabbit-mq
        ports:
        - containerPort: 15671
        - containerPort: 5671
        volumeMounts:
        - name: rabbit-mq-data
          mountPath: /etc/rabbitmq
          readOnly: false
        - name: mq-secret
          mountPath: /etc/rabbitmq/certfiles
          #readOnly: true
      volumes:
        - name: mq-secret
          secret:
            defaultMode: 420
            secretName: rabbit-mq-secrets
        - configMap:
            defaultMode: 420
            items:
            - key: rabbitmq.config
              path: rabbitmq.config
            name: mq-config
          name: rabbit-mq-data
like image 163
Oren Ashkenazy Avatar answered Sep 29 '22 23:09

Oren Ashkenazy