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

阿里云ack部署rabbitmq集群

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

这里需要注意的是:

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

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

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

登录后复制
cat mq-Account.yaml 
apiVersion: v1
kind: ServiceAccount
metadata:name: rabbitmqnamespace: service-rabbitmq
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:name: rabbitmqnamespace: service-rabbitmq
rules:
- apiGroups: [""]resources: ["endpoints"]verbs: ["get"]
- apiGroups: [""]resources: ["events"]verbs: ["create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:name: rabbitmqnamespace: service-rabbitmq
subjects:
- kind: ServiceAccountname: rabbitmq
roleRef:apiGroup: rbac.authorization.k8s.iokind: Rolename: rabbitmqcat mq-Configmap.yaml 
apiVersion: v1
kind: ConfigMap
metadata:name: rabbitmq-confignamespace: service-rabbitmq
data:rabbitmq.conf: |cluster_formation.peer_discovery_backend = k8scluster_formation.k8s.host = kubernetes.default.svc.cluster.localcluster_formation.k8s.address_type = hostnamecluster_formation.k8s.service_name = rabbitmq-headlessqueue_master_locator=min-mastersenabled_plugins: |[rabbitmq_management,rabbitmq_peer_discovery_k8s,rabbitmq_delayed_message_exchange].
# 按需启用插件cat mq-HeadlessService.yaml 
apiVersion: v1
kind: Service
metadata:name: rabbitmq-headlessnamespace: service-rabbitmq
spec:clusterIP: Noneports:- name: epmdport: 4369protocol: TCPtargetPort: 4369- name: cluster-linksport: 25672protocol: TCPtargetPort: 25672selector:app: rabbitmqsessionAffinity: Nonetype: ClusterIPcat mq-Service.yaml 
apiVersion: v1
kind: Service
metadata:name: rabbitmq-externalnamespace: service-rabbitmq
spec:ports:- name: httpport: 15672protocol: TCPtargetPort: 15672- name: amqpport: 5672protocol: TCPtargetPort: 5672selector:app: rabbitmqsessionAffinity: Nonetype: ClusterIPcat mq-Service.yaml 
apiVersion: v1
kind: Service
metadata:name: rabbitmq-externalnamespace: service-rabbitmq
spec:ports:- name: httpport: 15672protocol: TCPtargetPort: 15672- name: amqpport: 5672protocol: TCPtargetPort: 5672selector:app: rabbitmqsessionAffinity: Nonetype: ClusterIP
[root@jumpserver test1]# cat mq-StatefulSet.yaml 
apiVersion: apps/v1
kind: StatefulSet
metadata:name: rabbitmq-clusternamespace: service-rabbitmq
spec:replicas: 3selector:matchLabels:app: rabbitmqserviceName: rabbitmq-headlesstemplate:metadata:labels:app: rabbitmqspec:serviceAccountName: rabbitmqsecurityContext:fsGroup: 999runAsUser: 999runAsGroup: 999volumes:- name: config-volumeconfigMap:name: rabbitmq-configitems:- key: rabbitmq.confpath: "rabbitmq.conf"- key: enabled_pluginspath: "enabled_plugins"- name: rabbitmq-config-rwemptyDir: {}- name: rabbitmq-datapersistentVolumeClaim:claimName: nas-service-rabbitmq-pvcinitContainers:- name: initimage: harbor.hkfuliao.com/library/busybox:latestvolumeMounts:- name: config-volumemountPath: /tmp/rabbitmq- name: rabbitmq-config-rwmountPath: /etc/rabbitmqcommand:- sh- -c- cp /tmp/rabbitmq/rabbitmq.conf /etc/rabbitmq/rabbitmq.conf && echo '' >> /etc/rabbitmq/rabbitmq.conf;cp /tmp/rabbitmq/enabled_plugins /etc/rabbitmq/enabled_pluginscontainers:- name: rabbitmqimage: harbor.hkfuliao.com/service-rabbitmq/rabbitmq:3.9.13-managementlivenessProbe:exec:command: ["rabbitmq-diagnostics", "status"]initialDelaySeconds: 60periodSeconds: 60timeoutSeconds: 15readinessProbe:exec:command: ["rabbitmq-diagnostics", "ping"]initialDelaySeconds: 60periodSeconds: 60timeoutSeconds: 10ports:- name: amqpcontainerPort: 5672protocol: TCP- name: management-httpcontainerPort: 15672protocol: TCP- name: epmdcontainerPort: 4369protocol: TCPresources: limits:memory: 2Girequests:memory: 2Gienv:- name: MY_POD_NAMEvalueFrom:fieldRef:fieldPath: metadata.name  # get pod.metadata.name, e.g. rabbitmq-cluster-0- name: MY_POD_NAMESPACEvalueFrom:fieldRef:fieldPath: metadata.namespace  # get pod.metadata.namespace- name: RABBITMQ_DEFAULT_USERvalue: "admin"- name: RABBITMQ_DEFAULT_PASSvalue: "admin@123"- name: RABBITMQ_USE_LONGNAMEvalue: "true"- name: K8S_SERVICE_NAMEvalue: "rabbitmq-headless"- name: RABBITMQ_NODENAMEvalue: "rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local"- name: K8S_HOSTNAME_SUFFIXvalue: .$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local- name: RABBITMQ_ERLANG_COOKIEvalue: "91/rHX2a3GZw3RCHT1Q9y/G0Wo3cbX3qS06DyD4fAUs="    # generator by: echo $(openssl rand -base64 32)volumeMounts:- name: rabbitmq-config-rwmountPath: "/etc/rabbitmq"- name: rabbitmq-datamountPath: "/var/lib/rabbitmq/mnesia"

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

阿里云ack部署rabbitmq集群_TCP_02


http://www.mrgr.cn/news/79675.html

相关文章:

  • 新手从事直播软件源码开发搭建经验与技巧
  • Android四大组件——Activity(二)
  • PyTorch练习——张量的四则运算与矩阵运算
  • 我们来学mysql -- 探讨win安装方式(安装篇)
  • a few paper talked about software building process, so I learned
  • 电子应用设计方案-51:智能镜子系统方案设计
  • 【sgUploadList】自定义组件:基于elementUI的el-upload封装的上传列表组件,适用于上传附件时
  • 第4章:颜色和背景 --[CSS零基础入门]
  • unity中的UI介绍
  • 外包干了5天,技术明显退步。。。。。
  • 《蓝桥杯比赛规划》
  • unity 2D像素种田游戏学习记录(自用)
  • LearnOpenGL学习(高级OpenGL --> 帧缓冲,立方体贴图,高级数据)
  • kubeadm安装K8s集群之基础环境配置
  • VCU——matlab/simulink软件建模
  • ubuntu22.04 使用可以用的镜像源获取你要的镜像
  • Redisson分布式锁
  • Win10环境vscode+latex+中文快速配置
  • Java-JMX 组件架构即详解
  • Oracle DataGuard启动与关闭顺序
  • spring 源码分析
  • SQL语句在MySQL中如何执行
  • Linux Vi/Vim使用 ⑥
  • AKE 安全模型:CK, CK+, eCK
  • 计算机网络原理之HTTP与HTTPS
  • vue3-canvas实现在图片上框选标记(放大,缩小,移动,删除)