侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 144672 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

用Kubernetes管理RabbitMQ

2023-12-23 星期六 / 0 评论 / 0 点赞 / 22 阅读 / 2818 字

制作RabbitMQ的docker镜像 mq版本3.6.5 ## RabbitMQ Dockerfile## https://github.com/dockerfile/rabbitmq## Pull

制作RabbitMQ的docker镜像

mq版本3.6.5

## RabbitMQ Dockerfile## https://github.com/dockerfile/rabbitmq## Pull base image.FROM i71:5000/ubuntu# Add files.ADD bin/rabbitmq-start /usr/local/bin/RUN /  apt-get update && apt-get install -y wget # Install RabbitMQ.RUN /  /usr/bin/wget -qO - https://www.rabbitmq.com/rabbitmq-signing-key-public.asc | apt-key add - && /  echo "deb http://www.rabbitmq.com/debian/ testing main" > /etc/apt/sources.list.d/rabbitmq.list && /  apt-get update && /  DEBIAN_FRONTEND=noninteractive apt-get install -y rabbitmq-server --force-yes && /  rm -rf /var/lib/apt/lists/* && /  rabbitmq-plugins enable rabbitmq_management  rabbitmq_federation rabbitmq_federation_management && /  echo "[{rabbit, [{loopback_users, []}]}]." > /etc/rabbitmq/rabbitmq.config && /  chmod +x /usr/local/bin/rabbitmq-start# Define environment variables.ENV RABBITMQ_LOG_BASE /data/logENV RABBITMQ_MNESIA_BASE /data/mnesia# Define mount points.VOLUME ["/data/log", "/data/mnesia"]# Define working directory.WORKDIR /data# Define default command.CMD ["rabbitmq-start"]# Expose ports.EXPOSE 5672EXPOSE 15672

制作RabbitMQ的部署yaml文件

为了进行资源隔离,我将mq放入了单独的一个namespace,使用如下文件:rabbitmq-namespace.yaml

apiVersion: v1kind: Namespacemetadata:  name: mq-rtest

编写controller文件

rabbitmq-controller.yaml

apiVersion: v1kind: ReplicationControllermetadata:  name: mq  namespace: mq-rtest  labels:    name: mqspec:  replicas: 1  selector:    name: mq  template:    metadata:      labels:        name: mq    spec:      containers:      - name: mq        image: i71:5000/rabbitmq-3.6.5:latest        ports:        - containerPort: 5672        - containerPort: 15672        volumeMounts:        - name: rabbitmq-log          mountPath: /data/log          readonly: false        - name: rabbitmq-data          mountPath: /data/mnesia          readonly: false      volumes:      - name: rabbitmq-log        hostPath:          path: /home/data/rabbitmq3.6.5/log      - name: rabbitmq-data        hostPath:          path: /home/data/rabbitmq3.6.5/mnesia      nodeSelector:        nodename: i35

制作RabbitMQ service文件

apiVersion: v1kind: Servicemetadata:  name: mq  namespace: mq-rtest  labels:    name: mqspec:  type: NodePort  ports:  - port: 5672    name: mq-port    targetPort: 5672    nodePort: 32072  - port: 15672    name: mq-mgr-port    targetPort: 15672    nodePort: 32172  selector:    name: mq

 

广告 广告

评论区