K8S Helm安装RocketMQ standalone单机版,配置外网地址注册到nameserver中方便本地开发

K8S Helm安装RocketMQ standalone单机版,配置外网地址注册到nameserver中方便本地开发

helm地址

rocketmq 3.0.2 · sir5kong/rocketmq

helm repo add rocketmq https://helm-charts.itboon.top/rocketmq

helm pull rocketmq/rocketmq

tar -xvf rocketmq-3.0.2.tgz

修改配置

修改这个无效

/root/rocketmq/rocketmq/templates/borker/configmap.yaml

文件头有注释 {{/* 3.0 废弃 */}}

修改外网配置namesrvAddr、brokerIP1、listenPort

vi /root/rocketmq/rocketmq/templates/configmap.yaml

data:
  broker-base.conf: |
    brokerClusterName = {{ .Values.clusterName }}
{{- range $key, $value := .Values.broker.config }}
    {{ $key }} = {{ $value }}
{{- end }}
    namesrvAddr=你的外网地址加端口:3xxxx
    brokerIP1=你的外网地址
    listenPort=30911  
    将10911改成30911,k8s对外端口30000以上
    此时如此优秀的RocketMQ也会把你的10909和10912也会改成3打头的 30909(VIP) 30912(HA)
    

参考:RcoketMQ连接时报错sendDefaultImpl call timeout解决_rcoketmq send call timeout-CSDN博客

配置文件中的配置项:RocketMQ配置解析:手把手教老婆看懂broker.properties-CSDN博客

修改Borker中的端口

vi /root/rocketmq/rocketmq/templates/broker/statefulset.yaml

全换成3打头的

      ports:
        - containerPort: 30909
          name: vip
          protocol: TCP
        - containerPort: 30911
          name: main
          protocol: TCP
        - containerPort: 30912
          name: ha
          protocol: TCP

创建broker的service方便外网访问borker

vi broker-svc.yaml

apiVersion: v1
kind: Service
metadata:
  name: rocketmq-standalone-broker-master-svc-0
  labels:
spec:
  type: NodePort
  ports:
    - name: vip
      nodePort: 30909
      port: 30909
      targetPort: 30909
      protocol: TCP
    - name: main
      nodePort: 30911
      port: 30911
      targetPort: 30911
      protocol: TCP
    - name: ha
      nodePort: 30912
      port: 30912
      targetPort: 30912
      protocol: TCP

  selector:
      app.kubernetes.io/name: rocketmq
      broker: rocketmq-standalone-broker-master
      component: broker
      statefulset.kubernetes.io/pod-name: rocketmq-standalone-broker-master-0

kubectl apply -f broker-svc.yaml -n develop

修改/root/rocketmq/rocketmq/templates模板目录中nameservice和dashboard子目录中的service.yaml修改为NodePort并指定端口

spec:
  type: NodePort
  ports:
    nodePort: 3xxxx

安装rocketmq-standalone

helm install rocketmq-standalone /root/rocketmq/rocketmq \
  --namespace develop \
  --set image.tag="5.1.4" \ #使用新版本
  --set image.repository="apache/rocketmq" \ #或者你的私有仓库
  --set broker.persistence.storageClass="你的storageClass" --debug

反复检查

kubectl logs -f rocketmq-standalone-broker-master-0 -n develop

kubectl describe pod rocketmq-standalone-broker-master-0 -n develop

观察探针 readinessProbe

kubectl get pods -n develop -owide |grep rocket

kubectl get svc -n develop |grep rocket

rocketmq-standalone-broker-master-svc-0 NodePort 30909:30909/TCP,30911:30911/TCP,30912:30912/TCP

去dashboard中去看看是否正常

出错了卸载

helm uninstall rocketmq-standalone -n develop

创建个springboot工程访问试试

参考:SpringBoot集成RocketMQ(完整demo)_用springboot写一个简单使用rocketmq的demo-CSDN博客

上dashboard中的创建topic mq_test_topic

http://localhost:8080/test?msg=hello

在本地Git shell窗口里跑100个请求试试

for i in {1..100}; do curl http://localhost:8080/test?msg=hello && echo ""; done

去dashboard中去看看

你可能感兴趣的:(rocketmq,k8s,kubernetes,网络)