当前位置: 首页>后端>正文

rocketmq k8s yaml 一键脚本


kind: ConfigMap
apiVersion: v1
metadata:
  name: rocketmq-broker
  namespace: database

data:
  broker.conf: >-

    brokerClusterName=DefaultCluster
    brokerName=broker-a

    # 0 表示 Master,> 0 表示 Slave
    brokerId=0

    # nameServer地址,分号分割
    # namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876


    # 解决方式1 加上一句 producer.setVipChannelEnabled(false);,解决方式2 brokerIP1设置宿主机IP,不要使用docker 内部IP

    # brokerIP1=192.168.0.253


    # 在发送消息时,自动创建服务器不存在的topic,默认创建的队列数

    defaultTopicQueueNums=4


    # 是否允许 Broker 自动创建 Topic,建议线下开启,线上关闭 !!!这里仔细看是 false,false,false

    autoCreateTopicEnable=true


    # 是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭

    autoCreateSubscriptionGroup=true


    # Broker 对外服务的监听端口

    listenPort=10911


    # 删除文件时间点,默认凌晨4点

    deleteWhen=04


    # 文件保留时间,默认48小时

    fileReservedTime=120


    # commitLog 每个文件的大小默认1G

    mapedFileSizeCommitLog=1073741824


    # ConsumeQueue 每个文件默认存 30W 条,根据业务情况调整

    mapedFileSizeConsumeQueue=300000


    # destroyMapedFileIntervalForcibly=120000

    # redeleteHangedFileInterval=120000

    # 检测物理文件磁盘空间

    diskMaxUsedSpaceRatio=88



    maxMessageSize=65536


    # flushCommitLogLeastPages=4

    # flushConsumeQueueLeastPages=2

    # flushCommitLogThoroughInterval=10000

    # flushConsumeQueueThoroughInterval=60000


    # Broker 的角色

    # - ASYNC_MASTER 异步复制Master

    # - SYNC_MASTER 同步双写Master

    # - SLAVE

    brokerRole=ASYNC_MASTER


    # 刷盘方式

    # - ASYNC_FLUSH 异步刷盘

    # - SYNC_FLUSH 同步刷盘

    flushDiskType=ASYNC_FLUSH


    # 发消息线程池数量

    # sendMessageThreadPoolNums=128

    # 拉消息线程池数量

    # pullMessageThreadPoolNums=128

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: rocket-logs
  namespace: database
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: rocket-data
  namespace: database
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi

---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: rocketmq
  namespace: database
  labels:
    app: rocketmq

spec:
  replicas: 1
  selector:
    matchLabels:
      app: rocketmq
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: rocketmq

    spec:
      volumes:
        - name: volume-7bnc32
          persistentVolumeClaim:
            claimName: rocket-data
        - name: volume-wwyuhv
          persistentVolumeClaim:
            claimName: rocket-logs
      containers:
        - name: rmqnamesrv
          image: 'foxiswho/rocketmq:server'
          ports:
            - name: http-10909
              containerPort: 10909
              protocol: TCP
            - name: http-10911
              containerPort: 10911
              protocol: TCP
            - name: http-10912
              containerPort: 10912
              protocol: TCP
            - name: http-9876
              containerPort: 9876
              protocol: TCP
          resources: {}
          volumeMounts:
            - name: volume-7bnc32
              mountPath: /opt/store
            - name: volume-wwyuhv
              mountPath: /opt/logs
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: rocketmq-console
  namespace: database
  labels:
    app: rocketmq-console

spec:
  replicas: 1
  selector:
    matchLabels:
      app: rocketmq-console
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: rocketmq-console
    spec:
      containers:
        - name: console
          image: styletang/rocketmq-console-ng
          ports:
            - name: http-8080
              containerPort: 8080
              protocol: TCP
          env:
            - name: JAVA_OPTS
              value: >-
                -Drocketmq.namesrv.addr=rmqnamesrv:9876
                -Dcom.rocketmq.sendMessageWithVIPChannel=false
          resources: {}
          livenessProbe:
            httpGet:
              path: /
              port: 8080
              scheme: HTTP
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
---
kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: rmqbroker
  namespace: database
  labels:
    app: rmqbroker
  annotations:
    kubesphere.io/creator: admin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rmqbroker
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: rmqbroker

    spec:
      volumes:
        - name: volume-lez6kg
          persistentVolumeClaim:
            claimName: rocket-logs
        - name: volume-8um56e
          persistentVolumeClaim:
            claimName: rocket-data
        - name: volume-vthbyh
          configMap:
            name: rocketmq-broker
            defaultMode: 420
      containers:
        - name: brocker
          image: 'foxiswho/rocketmq:broker'
          command:
            - mqbroker
            - '-c'
            - /etc/rocketmq/broker.conf
          ports:
            - name: tcp-10909
              containerPort: 10909
              protocol: TCP
            - name: tcp-10911
              containerPort: 10911
              protocol: TCP
            - name: tcp-10912
              containerPort: 10912
              protocol: TCP
          env:
            - name: NAMESRV_ADDR
              value: 'rmqnamesrv:9876'
            - name: JAVA_OPTS
              value: ' -Duser.home=/opt'
            - name: JAVA_OPT_EXT
              value: '-server -Xms128m -Xmx128m -Xmn128m'
          resources: {}
          volumeMounts:
            - name: volume-lez6kg
              mountPath: /opt/logs
            - name: volume-8um56e
              mountPath: /opt/store
            - name: volume-vthbyh
              readOnly: true
              mountPath: /etc/rocketmq
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      schedulerName: default-scheduler
  serviceName: rmqbroker-o3zs
  podManagementPolicy: OrderedReady
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      partition: 0
  revisionHistoryLimit: 10

---
kind: Service
apiVersion: v1
metadata:
  name: rmqnamesrv
  namespace: database
  labels:
    app: rmqnamesrv
  annotations:
    kubesphere.io/creator: admin
spec:
  ports:
    - name: http-9876
      protocol: TCP
      port: 9876
      targetPort: 9876
  selector:
    app: rocketmq

  type: ClusterIP
  sessionAffinity: None
---
kind: Service
apiVersion: v1
metadata:
  name: rmqbroker-o3zs
  namespace: database
  labels:
    app: rmqbroker
  annotations:
    kubesphere.io/alias-name: rmqbroker
    kubesphere.io/creator: admin
    kubesphere.io/serviceType: statefulservice
spec:
  ports:
    - name: tcp-10909
      protocol: TCP
      port: 10909
      targetPort: 10909
    - name: tcp-10911
      protocol: TCP
      port: 10911
      targetPort: 10911
    - name: tcp-10912
      protocol: TCP
      port: 10912
      targetPort: 10912
  selector:
    app: rmqbroker
  clusterIP: None
  clusterIPs:
    - None
  type: ClusterIP
  sessionAffinity: None
---
kind: Service
apiVersion: v1
metadata:
  name: rocketmq-console
  namespace: database
  labels:
    app: rocketmq-console
  annotations:
    kubesphere.io/creator: admin
spec:
  ports:
    - name: http-8080
      protocol: TCP
      port: 8080
      targetPort: 8080
  selector:
    app: rocketmq-console

  type: NodePort
  sessionAffinity: None
  externalTrafficPolicy: Cluster

https://www.xamrdz.com/backend/3jj1941280.html

相关文章: