美文网首页
RabbitMQ Operator on Kubernetes

RabbitMQ Operator on Kubernetes

作者: onmeiei | 来源:发表于2021-12-08 15:41 被阅读0次

下载Operator定义

下载rmq operator定义 - cluster-operator.yml

创建本地PV存储

本地PV存储需要创建多个,以三节点为例(官方文档写明建议奇数,且只测了1、3、5,再多的就没测试过了),需要创建三个,在pv目录中新建三个pv-xxxx.yaml,以其中一个为例:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-rmq-lthpc
  # 重要,innodb选择pv时使用
  labels:
    pv: pv-rmq
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-storage
  local:
    # 实际的存储路径
    path: /k8s-pv/rmq
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - lthpc

通过以下命令进行创建:

$ kubectl apply -f pv/

创建rabbitmq cluster集群,三节点

RabbitmqCluster集群定义文件rmq.yaml的内容如下:

apiVersion: v1
kind: Namespace
metadata:
  name: messaging
---
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: rmq-eyecool
  namespace: messaging
spec:
  replicas: 3
  service:
    type: ClusterIP
  persistence:
    storageClassName: 'local-storage'
    storage: 1Gi

执行如下命令:

$ kubectl apply -f rmq.yaml

将管理端口通过ingress暴露

ingress.yaml内容如下

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-rmq
  namespace: messaging
spec:
  ingressClassName: nginx
  rules:
  - host: rmq.eyecool.cn
    http:
      paths:
      - backend:
          service:
            name: rmq-eyecool
            port:
              number: 15672
        path: /
        pathType: Prefix

通过以下命令进行创建

$ kubectl create -f ingress.yaml

注意:ingress nginx需要单独安装,请参考kubernetes ingress - 简书 (jianshu.com)

相关文章

网友评论

      本文标题:RabbitMQ Operator on Kubernetes

      本文链接:https://www.haomeiwen.com/subject/bzstfrtx.html