如何在kubernetes上安装Rabbitmq插件? [英] How to install rabbitmq plugin on kubernetes?

查看:420
本文介绍了如何在kubernetes上安装Rabbitmq插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Kubernetes环境,其中有一个Rabbitmq服务台,部署了2盒RabbitMq.

I have a Kubernetes environment with a rabbitmq servirve who deploys 2 pods of rabbitmq.

我需要在Rabbitmq(延迟消息插件)上安装一个插件,但是我不喜欢这种手动"方式,因此,如果删除了pod,我必须再次安装该插件.

I need to install a plugin on rabbitmq, (Delayed Message Plugin) but I don't like the "manual" way, so if the pod is deleted, I have to install the plugin again.

我想知道哪种是实现此目标的推荐方法.

I want to know which is the recommended way of achieving this.

仅供参考:手动方法是将文件复制到plugins文件夹中,然后启动以下命令:

FYI: the manual way is to copy a file into the plugins folder, and then launch the following command:

rabbitmq-plugins enable rabbitmq_delayed_message_exchange

推荐答案

您应该从配置映射中安装RabbitMQ的配置.

You should mount the configuration for RabbitMQ from a config map.

例如:

ConfigMap:

The ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: rabbitmq-config
  namespace: rabbitmq
data:
  enabled_plugins: |
      [rabbitmq_management,rabbitmq_peer_discovery_k8s].
  rabbitmq.conf: |
      ...
  definitions.json: |
      ...

然后在您的Deployment或StatefulSet中:

And then in your Deployment or StatefulSet:

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: rabbitmq
  namespace: rabbitmq
spec:
  replicas: 3
  ...
  template:
    ...
    spec:
      containers:
      - image: rabbitmq:3.7.4-management-alpine
        imagePullPolicy: IfNotPresent
        name: rabbitmq
        volumeMounts:
        - name: config-volume
          mountPath: /etc/rabbitmq
        ...
      volumes:
        - name: config-volume
          configMap:
            name: rabbitmq-config
            items:
            - key: rabbitmq.conf
              path: rabbitmq.conf
            - key: enabled_plugins
              path: enabled_plugins
            - key: definitions.json
              path: definitions.json
       ...

首先有几种安装插件的方法.一种是基于当前使用的图像,添加插件,然后使用新图像.或者,您可以使用 Kubernetes生命周期钩子来预先下载文件开始.这是 postStart示例

There are several ways to install the plugin in the first place. One is to base off of the image you are currently using, add the plugin, and use the new image instead. Alternatively you could utilize Kubernetes life cycle hooks to download the file pre start. Here is an example of postStart

这篇关于如何在kubernetes上安装Rabbitmq插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆