当前位置: 首页 > article >正文

阿里云ack部署rabbitmq集群

1、创建持久化存储pv和pvc,我整理使用的是阿里云的NAS。

这里需要注意的是:

  • 设置下子目录,避免共用 NAS 时,文件组织混乱。
  • 给子目录分配权限,我这里设置的是777。

阿里云ack部署rabbitmq集群_子目录

2、创建服务部署的yaml文件。

登录后复制
cat mq-Account.yaml 
apiVersion: v1
kind: ServiceAccount
metadata:
  name: rabbitmq
  namespace: service-rabbitmq
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: rabbitmq
  namespace: service-rabbitmq
rules:
- apiGroups: [""]
  resources: ["endpoints"]
  verbs: ["get"]
- apiGroups: [""]
  resources: ["events"]
  verbs: ["create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: rabbitmq
  namespace: service-rabbitmq
subjects:
- kind: ServiceAccount
  name: rabbitmq
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: rabbitmq





cat mq-Configmap.yaml 
apiVersion: v1
kind: ConfigMap
metadata:
  name: rabbitmq-config
  namespace: service-rabbitmq
data:
  rabbitmq.conf: |
    cluster_formation.peer_discovery_backend = k8s
    cluster_formation.k8s.host = kubernetes.default.svc.cluster.local
    cluster_formation.k8s.address_type = hostname
    cluster_formation.k8s.service_name = rabbitmq-headless
    queue_master_locator=min-masters
  enabled_plugins: |
    [rabbitmq_management,rabbitmq_peer_discovery_k8s,rabbitmq_delayed_message_exchange].
# 按需启用插件





cat mq-HeadlessService.yaml 
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-headless
  namespace: service-rabbitmq
spec:
  clusterIP: None
  ports:
    - name: epmd
      port: 4369
      protocol: TCP
      targetPort: 4369
    - name: cluster-links
      port: 25672
      protocol: TCP
      targetPort: 25672
  selector:
    app: rabbitmq
  sessionAffinity: None
  type: ClusterIP





cat mq-Service.yaml 
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-external
  namespace: service-rabbitmq
spec:
  ports:
    - name: http
      port: 15672
      protocol: TCP
      targetPort: 15672
    - name: amqp
      port: 5672
      protocol: TCP
      targetPort: 5672
  selector:
    app: rabbitmq
  sessionAffinity: None
  type: ClusterIP






cat mq-Service.yaml 
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-external
  namespace: service-rabbitmq
spec:
  ports:
    - name: http
      port: 15672
      protocol: TCP
      targetPort: 15672
    - name: amqp
      port: 5672
      protocol: TCP
      targetPort: 5672
  selector:
    app: rabbitmq
  sessionAffinity: None
  type: ClusterIP
[root@jumpserver test1]# cat mq-StatefulSet.yaml 
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: rabbitmq-cluster
  namespace: service-rabbitmq
spec:
  replicas: 3
  selector:
    matchLabels:
      app: rabbitmq
  serviceName: rabbitmq-headless
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      serviceAccountName: rabbitmq
      securityContext:
        fsGroup: 999
        runAsUser: 999
        runAsGroup: 999
      volumes:
        - name: config-volume
          configMap:
            name: rabbitmq-config
            items:
            - key: rabbitmq.conf
              path: "rabbitmq.conf"
            - key: enabled_plugins
              path: "enabled_plugins"
        - name: rabbitmq-config-rw
          emptyDir: {}
        - name: rabbitmq-data
          persistentVolumeClaim:
            claimName: nas-service-rabbitmq-pvc
      initContainers:
      - name: init
        image: harbor.hkfuliao.com/library/busybox:latest
        volumeMounts:
        - name: config-volume
          mountPath: /tmp/rabbitmq
        - name: rabbitmq-config-rw
          mountPath: /etc/rabbitmq
        command:
        - sh
        - -c
        - cp /tmp/rabbitmq/rabbitmq.conf /etc/rabbitmq/rabbitmq.conf && echo '' >> /etc/rabbitmq/rabbitmq.conf;
          cp /tmp/rabbitmq/enabled_plugins /etc/rabbitmq/enabled_plugins
      containers:
        - name: rabbitmq
          image: harbor.hkfuliao.com/service-rabbitmq/rabbitmq:3.9.13-management
          livenessProbe:
            exec:
              command: ["rabbitmq-diagnostics", "status"]
            initialDelaySeconds: 60
            periodSeconds: 60
            timeoutSeconds: 15
          readinessProbe:
            exec:
              command: ["rabbitmq-diagnostics", "ping"]
            initialDelaySeconds: 60
            periodSeconds: 60
            timeoutSeconds: 10
          ports:
            - name: amqp
              containerPort: 5672
              protocol: TCP
            - name: management-http
              containerPort: 15672
              protocol: TCP
            - name: epmd
              containerPort: 4369
              protocol: TCP
          resources: 
            limits:
              memory: 2Gi
            requests:
              memory: 2Gi
          env:
            - name: MY_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name  # get pod.metadata.name, e.g. rabbitmq-cluster-0
            - name: MY_POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace  # get pod.metadata.namespace
            - name: RABBITMQ_DEFAULT_USER
              value: "admin"
            - name: RABBITMQ_DEFAULT_PASS
              value: "admin@123"
            - name: RABBITMQ_USE_LONGNAME
              value: "true"
            - name: K8S_SERVICE_NAME
              value: "rabbitmq-headless"
            - name: RABBITMQ_NODENAME
              value: "rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local"
            - name: K8S_HOSTNAME_SUFFIX
              value: .$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local
            - name: RABBITMQ_ERLANG_COOKIE
              value: "91/rHX2a3GZw3RCHT1Q9y/G0Wo3cbX3qS06DyD4fAUs="    # generator by: echo $(openssl rand -base64 32)
          volumeMounts:
            - name: rabbitmq-config-rw
              mountPath: "/etc/rabbitmq"
            - name: rabbitmq-data
              mountPath: "/var/lib/rabbitmq/mnesia"

3、创建ingress路由,15672端口映射到指定域名上,然后DNS解析到此ingress的公网IP即可

阿里云ack部署rabbitmq集群_TCP_02


http://www.kler.cn/a/430120.html

相关文章:

  • 数据结构:栈(Stack)和队列(Queue)—面试题(一)
  • Jenkins pipeline 发送邮件及包含附件
  • Fastapi + vue3 自动化测试平台(1)--开篇
  • 68.基于SpringBoot + Vue实现的前后端分离-心灵治愈交流平台系统(项目 + 论文PPT)
  • Mac中配置vscode(第一期:python开发)
  • 微信小程序map组件所有markers展示在视野范围内
  • 网络原理之 TCP 协议
  • 启动hbase后没有hmaster进程
  • 二一(GIT4)、echarts(地图)、黑马就业数据平台(学生页-增 删 改)
  • 【论文阅读】Fifty Years of the ISCA: A Data-Driven Retrospective
  • 什么是厄尔米特(Hermitian)矩阵?
  • PHP:将数据传递给Grid++Report模板进行打印
  • 棋牌项目Go的日志打印问题
  • workflow笔记
  • WebSocket 经验与最佳实践
  • 《跨越平台壁垒:C++ 人工智能模型在移动设备的部署之路》
  • java+ssm+mysql校园物品租赁网
  • C#请求https提示未能为 SSL/TLS 安全通道建立信任关系
  • XREAL在日本AR市场成功的策略分析
  • Mysql | 尚硅谷 | 第02章_MySQL环境搭建
  • linux 安装 vsftpd 服务以及配置全攻略,vsftpd 虚拟多用户多目录配置,为每个用户配置不同的使用权限
  • 【前端】深度解析 JavaScript 中的 new 关键字与构造函数
  • 【ETCD】【源码阅读】configurePeerListeners() 函数解析
  • 数据结构——哈夫曼树
  • 【电控笔记z46】非线性磁链笔记
  • Spring Boot 3.3.4 升级导致 Logback 之前回滚策略配置不兼容问题解决