部署前准备:
k8s集群,详见k8s集群搭建。
部署机型:本集群有3个master节点,3 个 worknode 节点,rabbitMQ副本3个,则由k8s自由调度到各个工作节点中。
一、编写集群yaml文件,rabbitmq-cluster.yaml。
apiVersion: v1
kind: ServiceAccount
metadata:
name: rabbitmq
namespace: sit
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: rabbitmq
namespace: sit
rules:
- apiGroups:
- ""
resources:
- endpoints
verbs:
- get
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: rabbitmq
namespace: sit
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: rabbitmq
subjects:
- kind: ServiceAccount
name: rabbitmq
namespace: sit
---
kind: Service
apiVersion: v1
metadata:
name: rabbitmq-service #rabbit以外使用
namespace: sit
spec:
type: NodePort
ports:
- name: mangement
protocol: TCP
port: 15672
nodePort: 31002
- name: smp
protocol: TCP