使用kubernetes进行rabbit-mq部署

问题描述 投票:1回答:1

我正在从docker-compose迁移到kubernetes。我们使用的服务之一是rabbitmq。当我尝试部署rabbit-mq 3.6.16-management时,我收到错误:

/usr/local/bin/docker-entrypoint.sh:line 382:/etc/rabbitmq/rabbitmq.config:权限被拒绝。

虽然它适用于docker-compose部署。

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"

多克尔 - 撰写:

  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
docker kubernetes rabbitmq kubectl
1个回答
1
投票

最终我使用了configmap和secret来挂载文件而不是PV,并按预期工作。

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
© www.soinside.com 2019 - 2024. All rights reserved.