# EMQX

例子

apiVersion: apps.emqx.io/v1beta2
kind: EmqxBroker
metadata:
  name: emqx
spec:
  serviceAccountName: "emqx"
  image: emqx/emqx:4.3.11
  replicas: 3
  labels:
    cluster: emqx
  storage:
    storageClassName: standard
    resources:
      requests:
        storage: 20Mi
    accessModes:
    - ReadWriteOnce
  emqxTemplate:
    listener:
      type: ClusterIP
      ports:
        mqtt: 1883
        mqtts: 8883
        ws: 8083
        wss: 8084
        dashboard: 18083
        api: 8081
    acl:
      - permission: allow
        username: "dashboard"
        action: subscribe
        topics:
          filter:
            - "$SYS/#"
            - "#"
      - permission: allow
        ipaddress: "127.0.0.1"
        topics:
          filter:
            - "$SYS/#"
          equal:
            - "#"
      - permission: deny
        action: subscribe
        topics:
          filter:
            - "$SYS/#"
          equal:
            - "#"
      - permission: allow
    plugins:
      - name: emqx_management
        enable: true
      - name: emqx_recon
        enable: true
      - name: emqx_retainer
        enable: true
      - name: emqx_dashboard
        enable: true
      - name: emqx_telemetry
        enable: true
      - name: emqx_rule_engine
        enable: true
      - name: emqx_bridge_mqtt
        enable: false
    modules:
      - name: emqx_mod_acl_internal
        enable: true
      - name: emqx_mod_presence
        enable: true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  • 配置镜像地址
image: my-repo/emqx:4.3.10
1
  • 配置存储
storage:
volumeClaimTemplate:
  spec:
    storageClassName: standard
    resources:
      requests:
        storage: 20Mi
    accessModes:
    - ReadWriteOnce
1
2
3
4
5
6
7
8
9
FieldDefaultDescription
storageClassNamestandard存储类的名称
storage20Mi存储容量
accessModesReadWriteOnce挂载模式,有 ReadWriteOnce,ReadOnlyMany 和 ReadWriteMany
  • 配置 Load Balancer
listener:
  type: ClusterIP
  ports:
    mqtt: 1883
    mqtts: 8883
    ws: 8083
    wss: 8084
    dashboard: 18083
    api: 8081
1
2
3
4
5
6
7
8
9
FieldDefaultDescription
typeClusterIP监听器类型,可以配置为 ClusterIP 或者 LoadBalancer
portsmqtt: 1883 mqtts: 8883 ws: 8083 wss: 8084 dashboard: 18083 api: 8081EMQX 端口名称 详细请参考 EMQX 官方文档 (opens new window)

当 type 设置为 LoadBalancer,各个云平台需要配置不同的 annotations,例如在 EKS 平台设置为: service.beta.kubernetes.io/aws-load-balancer-type: nlb

  • 配置ACL
acl:
  - permission: allow
    username: "dashboard"
    action: subscribe
    topics:
      filter:
        - "$SYS/#"
        - "#"
  - permission: allow
    ipaddress: "127.0.0.1"
    topics:
      filter:
        - "$SYS/#"
      equal:
        - "#"
  - permission: deny
    action: subscribe
    topics:
      filter:
        - "$SYS/#"
      equal:
        - "#"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
FieldDescription
permission执行权限控制操作,可取值为 allow,deny
username用户名 (username)为 "dashboard" 的用户生效
action规则所控制的操作,可取值为 publish,subscribe,pubsub
topics.filter主题过滤器,表示规则可以匹配的主题
  • 配置插件(plugins)
plugins:
  - name: emqx_management
    enable: true
  - name: emqx_recon
    enable: true
  - name: emqx_retainer
    enable: true
  - name: emqx_dashboard
    enable: true
  - name: emqx_telemetry
    enable: true
  - name: emqx_rule_engine
    enable: true
  - name: emqx_bridge_mqtt
    enable: false
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FieldDescription
name插件名称
enable启用或者禁用插件,可取值 true 或者 false

详细信息可参考官方文档 (opens new window)

  • 配置模块(modules)
modules:
  - name: emqx_mod_acl_internal
    enable: true
  - name: emqx_mod_presence
    enable: true
1
2
3
4
5
FieldDescription
name模块名称
enable启用或者禁用模块,可取值true或者false

详细信息可参考官方文档 (opens new window)

  • 配置 license(针对 EMQX 企业版)
FieldDefaultDescription
license不配license内容
  • 配置Prometheus监控
plugins:
  - name: emqx_prometheus
    enable: true
env:
  - name: EMQX_PROMETHEUS__PUSH__GATEWAY__SERVER
    value: ${push_gateway_url}:9091
1
2
3
4
5
6
FieldDescription
env.name环境变量的名称
env.value环境变量的值
本页导航