一、部署rocketMq
apiVersion: apps/v1 kind: Deployment metadata: labels: app: rocketmq-broker name: rocketmq-broker namespace: default spec: replicas: 1 selector: matchLabels: app: rocketmq-broker template: metadata: labels: app: rocketmq-broker spec: containers: - env: - name: NAMESRV_ADDR #通过环境变量指定namesrv 地址,注意该值为namesrv svc地址 value: rocketmq-dialevoneid:9876 image: rocketmqinc/rocketmq:4.4.0 command: ["/bin/sh","mqbroker"] name: rocketmq-broker ports: - containerPort: 10909 name: tcp-10909 protocol: TCP - containerPort: 10911 name: tcp-10911 protocol: TCP - containerPort: 10912 name: tcp-10912 protocol: TCP resources: limits: memory: 1200Mi requests: memory: 1200Mi
2.namesrv
apiVersion: apps/v1 kind: Deployment metadata: labels: app: rocketmq-namesrv name: rocketmq-namesrv namespace: default spec: replicas: 1 selector: matchLabels: app: rocketmq-namesrv template: metadata: labels: app: rocketmq-namesrv spec: containers: - image: rocketmqinc/rocketmq:4.4.0 name: rockermq-namesrv command: ["/bin/sh","mqnamesrv"] ports: - containerPort: 9876 name: tcp-9876 protocol: TCP resources: limits: memory: 600Mi requests: memory: 600Mi
3.console
apiVersion: apps/v1 kind: Deployment metadata: labels: app: rocketmq-dashboard name: rocketmq-dashboard namespace: default spec: replicas: 1 selector: matchLabels: app: rocketmq-dashboard template: metadata: labels: app: rocketmq-dashboard spec: containers: - env: - name: JAVA_OPTS value: -Drocketmq.namesrv.addr=rocketmq-dialevoneid:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false #注意替换此处namesrv svc的名称 image: styletang/rocketmq-console-ng name: rocketmq-dashboard
4.rocketMq namesrv svc
apiVersion: v1 kind: Service metadata: labels: app: rocketmq-dialevoneid name: rocketmq-dialevoneid namespace: default spec: ports: - name: tcp-9876 port: 9876 protocol: TCP targetPort: 9876 selector: app: rocketmq-namesrv
5.rocketMq console svc
apiVersion: v1 kind: Service metadata: labels: app: rocketmq-dashboard name: rocketmq-dashboard namespace: default spec: ports: - port: 8080 protocol: TCP targetPort: 8080 selector: app: rocketmq-dashboard
6.rocketMq console ingress
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-rocketmq namespace: default spec: rules: - host: rocketmq.xxxx.com http: paths: - backend: service: name: rocketmq-dashboard port: number: 8080 path: / pathType: ImplementationSpecific
7.注意事项
日志、 消息存储目录 rocket namesrv配置等目录建议使用持久化存储,其他注意替换对应的svc名称 名称空间,镜像默认存储在用户家目录下,可以通过配置文件修改