Skip to content

EMQX設定の変更

目的

EMQXカスタムリソースの.spec.config.dataフィールドを使用して、EMQXの設定を変更します。

EMQXクラスターの設定

EMQX CRD apps.emqx.io/v2beta1は、.spec.config.dataフィールドを通じてEMQXクラスターの設定をサポートしています。完全な設定リファレンスについては、設定マニュアルを参照してください。

EMQXは設定ファイル形式としてHOCONを使用しています。

  1. 以下の内容をYAMLファイルとして保存し、kubectl applyでデプロイします。

    yaml
    apiVersion: apps.emqx.io/v2
    kind: EMQX
    metadata:
       name: emqx
    spec:
       image: emqx/emqx:6.2.0
       imagePullPolicy: IfNotPresent
       config:
          # ポート1884で待ち受けるTCPリスナー`test`を設定します:
          data: |
             listeners.tcp.test {
                bind = "0.0.0.0:1884"
                max_connections = 1024000
             }
             license {
               key = "..."
             }
       listenersServiceTemplate:
          spec:
             type: LoadBalancer
       dashboardServiceTemplate:
          spec:
             type: LoadBalancer

    TIP

    .spec.config.dataフィールドの内容は、EMQXコンテナに対してemqx.conf設定ファイルとして提供されます。

  2. EMQXクラスターが準備完了になるまで待ちます。kubectl getコマンドでEMQXクラスターのステータスを確認し、STATUSReadyであることを確認してください。完了までに時間がかかる場合があります。

    bash
    $ kubectl get emqx emqx
    NAME   STATUS   AGE
    emqx   Ready    10m

設定の確認

EMQXのリスナーの状態を確認します。

bash
$ kubectl exec -it emqx-core-0 -c emqx -- emqx ctl listeners
tcp:default
   listen_on: 0.0.0.0:1883
   acceptors: 16
   proxy_protocol : false
   running: true
   current_conn: 0
   max_conns : 1024000
tcp:test
   listen_on: 0.0.0.0:1884
   acceptors: 16
   proxy_protocol : false
   running: true
   current_conn: 0
   max_conns : 1024000

ここで、ポート1884で新たに設定したリスナーが稼働していることが確認できます。