首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Kubernetes建立Mosquitto经纪人

如何在Kubernetes建立Mosquitto经纪人
EN

Server Fault用户
提问于 2020-12-10 15:10:17
回答 1查看 10.7K关注 0票数 6

我一直试图在Kubernetes空间中设置ChirpStack,但它似乎并不适合我,而且我也找不到任何解决方案的在线资源。

代码语言:javascript
复制
**chirpstack-application-server-6d6f8d699c-nlrmx   1/1     Running            0          44s\
chirpstack-gateway-bridge-5454b7f9f-fm5wl          1/1     Running            0          73s\
chirpstack-mosquitto-646899d74d-d7bhl              0/1     CrashLoopBackOff   3          85s\
chirpstack-network-server-66cdf9bdf7-rhzg5         1/1     Running            0          55s**

上面是我所有的自动取款机。应用服务器,网络服务器,网关桥都是旋转和运行的,然而,摩斯基托经纪人移动到‘完成’,并直接进入CrashLoopBackOff。

我认为这可能与配置不足有关,因此我花了几天时间将mosquitto.conf文件与"allow_anonymous true“放在一起,希望从任何ChirpStack组件获得一个连接,但日志仅仅表明mqtt连接被拒绝错误。

库贝特日志的

输出-应用程序-服务器

代码语言:javascript
复制
time="2020-12-10T15:01:41Z" level=error msg="integration/mqtt: connecting to broker error, will retry in 2s: Network Error : dial tcp 10.244.146.236:1883: i/o timeout"

因为无法建立连接,所以我认为情况正好相反,我需要添加password_file并使allow_anonymous变为false。下面是我的当前配置,如果有人可能知道什么是错误的。

configMap-1.yml

代码语言:javascript
复制
kind: ConfigMap
metadata:
  name: mosquitto-password
  namespace: ****
  labels:
    app: chirpstack-mosquitto  
data:
  password_file.txt: |
    admin:admin
    user:user
    app-server:app-server
    net-server:net-server
    gateway-bridge:gateway-bridge

configMap.yml

代码语言:javascript
复制
kind: ConfigMap
metadata:
  name: mosquitto-config
  namespace: ****
  labels:
    app: chirpstack-mosquitto  
data:
  mosquitto.conf: |    
    persistence true
    persistence_location /mosquitto/data/
    # per_listener_settings false
    log_dest stdout
    # listener 1886
    listener 1883
    protocol mqtt
    # Defaults to false, unless there are no listeners defined in the configuration
    # file, in which case it is set to true, but connections are only allowed from
    # the local machine.
    allow_anonymous false
    password_file /.config/mosquitto/auth/password_file.txt
    #    cafile: /mosquitto/config/certs/ca.crt
    #    certfile: /mosquitto/config/certs/server.crt
    #    keyfile: /mosquitto/config/certs/server.key
    require_certificate false
    use_identity_as_username false

deployment.yml

代码语言:javascript
复制
kind: Deployment
metadata:
  name: chirpstack-mosquitto
  namespace: ****  
spec:
  replicas: 1
  selector:
    matchLabels:
      app: chirpstack-mosquitto
  template:
    metadata:
      labels:
        app: chirpstack-mosquitto
    spec:
      containers:
      - name: chirpstack-mosquitto
        image: ****/chirpstack/eclipse-mosquitto:1.6.12
        ports:
        - containerPort: 1883
        volumeMounts:
        - name: password-file
          mountPath: /.config/mosquitto/auth/password_file.txt
          subPath: password_file.txt
        - name: mosquitto-data
          mountPath: /mosquitto/data
        - name: mosquitto-log
          mountPath: /mosquitto/log
        - name: config-file
          mountPath: /.config/mosquitto/mosquitto.conf
          subPath: mosquitto.conf         
      securityContext:
        runAsNonRoot: true
        fsGroup: 1
        runAsGroup: 1000
        runAsUser: 1000
        supplementalGroups:
        - 1    
      volumes:
      - name: config-file
        configMap:
          name: mosquitto-config
      - name: password-file
        configMap:
          name: mosquitto-password        
      - name: mosquitto-data
        emptyDir: {}
      - name: mosquitto-log
        emptyDir: {}   

service.yml

代码语言:javascript
复制
kind: Service
metadata:
  name: chirpstack-mosquitto
  namespace: 186215-poc  
spec:
  type: ClusterIP
  ports:
    - name: mqtt 
      port: 1883
      targetPort: 1883
      protocol: TCP  
  selector:
    app: chirpstack-mosquitto    
EN

回答 1

Server Fault用户

发布于 2022-09-18 16:44:50

遵循以下步骤:

  1. git克隆https://github.com/halkeye-helm-charts/mosquitto.git
  2. 修改values.yaml文件,添加NodePort或LoadBalancer并启用storageClass。服务:类型: NodePort持久性: storageClass:"oci-bv“
  3. 通过舵图部署:helm install mosquitto --generate-name
  4. 见蚊荚原木:kubectl logs pod/mosquitto-service-name。例如:
  1. 测试服务:订户: docker run -it -rm-name mqtt-订户efrecon/mqtt-client sub ip_address -p port -t "/#“Publisher: docker run -it -rm-name mqtt-publisher efrecon/mqtt-client pub -h ip- address "SOOntestMessage”-p port -t "/test“
  2. 您应该在订阅服务器上接收消息:
票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1045712

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档