k8s部署rocketmq5.1.4
【代码】k8s部署rocketmq5.1.4。
·
broker配置文件
#[root@node101 broker]# cat broker.conf
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# Broker服务地址 String 内部使用填内网ip,如果是需要给外部使用填公网ip
brokerIP1 = 192.168.0.101
# 端口(注意:broker启动后,会占用3个端口,分别在listenPort基础上-2,+1,供内部程序使用,所以集群一定要规划好端口,避免冲突)
listenPort=31005
k8s部署文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: ssx-rocketmq-dmsv
namespace: ssx
spec:
replicas: 1
selector:
matchLabels:
app: ssx-rocketmq-dmsv
template:
metadata:
labels:
app: ssx-rocketmq-dmsv
spec:
hostAliases:
- hostnames:
- node101
ip: 192.168.0.101
- hostnames:
- node102
ip: 192.168.0.102
- hostnames:
- node103
ip: 192.168.0.103
containers:
- name: ssx-rocketmq-namesrv-c
image: docker.io/apache/rocketmq:5.1.4
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9876
volumeMounts:
- mountPath: /home/rocketmq/logs
name: c-v-path-rocketmq-namesrv-logs
- mountPath: /etc/localtime
name: c-v-path-time
env:
- name: MAX_POSSIBLE_HEAP
value: "100000000" #环境变量的值 因为是纯数字,需要添加双引号 不然编译报错
- name: Xms
value: 512M
- name: Xmx
value: 512M
- name: Xmn
value: 128M
command: ["sh"]
args: ["mqnamesrv"]
- name: ssx-rocketmq-broker-c
image: docker.io/apache/rocketmq:5.1.4
imagePullPolicy: IfNotPresent
ports:
- containerPort: 31005
- containerPort: 31006
- containerPort: 31003
volumeMounts:
- mountPath: /home/rocketmq/logs
name: c-v-path-rocketmq-broker-logs
- mountPath: /home/rocketmq/store
name: c-v-path-rocketmq-broker-store
- mountPath: /home/rocketmq/broker.conf
name: c-v-path-rocketmq-broker-configfile
- mountPath: /etc/localtime
name: c-v-path-time
env:
- name: NAMESRV_ADDR
value: localhost:9876
- name: Xms
value: 512M
- name: Xmx
value: 512M
- name: Xmn
value: 128M
- name: MAX_POSSIBLE_HEAP
value: "200000000"
command: ["sh"]
args: ["mqbroker","-c", "/home/rocketmq/broker.conf"]
- name: ssx-rocketmq-console-c
image: docker.io/apacherocketmq/rocketmq-dashboard:1.0.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /etc/localtime
name: c-v-path-time
env:
- name: JAVA_OPTS
value: -Drocketmq.namesrv.addr=localhost:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false
volumes:
- name: c-v-path-rocketmq-namesrv-logs
hostPath:
path: /home/app/apps/k8s/for_docker_volume/rocketmq/namesrv/logs
- name: c-v-path-rocketmq-broker-configfile
hostPath:
path: /home/app/apps/k8s/for_docker_volume/rocketmq/broker/broker.conf
- name: c-v-path-rocketmq-broker-logs
hostPath:
path: /home/app/apps/k8s/for_docker_volume/rocketmq/broker/logs
- name: c-v-path-rocketmq-broker-store
hostPath:
path: /home/app/apps/k8s/for_docker_volume/rocketmq/broker/store
- name: c-v-path-time #设置容器的时区和宿主机保持一致
hostPath:
path: /etc/localtime
nodeSelector: #把此pod部署到指定的node标签上
kubernetes.io/hostname: node101
---
apiVersion: v1
kind: Service
metadata:
name: ssx-rocketmq-dmsv
namespace: ssx
spec:
ports:
- port: 8080
name: ssx-rocketmq-console
protocol: TCP
targetPort: 8080
- port: 9876
name: ssx-rocketmq-namesrv
protocol: TCP
targetPort: 9876
nodePort: 31002
- port: 10911
name: ssx-rocketmq-broker-10911
protocol: TCP
targetPort: 31005
nodePort: 31005
- port: 10912
name: ssx-rocketmq-broker-10912
protocol: TCP
targetPort: 31006
nodePort: 31006
- port: 10909
name: ssx-rocketmq-broker-10909
protocol: TCP
targetPort: 31003
nodePort: 31003
selector:
app: ssx-rocketmq-dmsv
type: NodePort
更多推荐
已为社区贡献11条内容
所有评论(0)