Here are the relevant configurations for EMQX Custom Resource. You can choose the corresponding APIVersion based on the version of EMQX you wish to deploy. For specific compatibility relationships, please refer to EMQX Operator Compatibility:
EMQX CRD supports using .spec.dashboardServiceTemplate to configure EMQX cluster Dashboard Service, using .spec.listenersServiceTemplate to configure EMQX cluster listener Service, its documentation can refer to Service(opens new window).
By default, EMQX will open an MQTT TCP listener tcp-default corresponding to port 1883 and Dashboard listener dashboard-listeners-http-bind corresponding to port 18083. Users can add new listeners through .spec.bootstrapConfig field or EMQX Dashboard. EMQX Operator will automatically inject the default listener information into the Service when creating the Service, but when there is a conflict between the Service configured by the user and the listener configured by EMQX (name or port fields are repeated), EMQX Operator will use the user's configuration prevail.
Save the above content as emqx.yaml and execute the following command to deploy the EMQX cluster:
$ kubectl apply -f emqx.yaml
emqx.apps.emqx.io/emqx created
1 2 3
Check the status of the EMQX cluster and make sure that STATUS is Running, which may take some time to wait for the EMQX cluster to be ready.
$ kubectl get emqx emqx
NAME IMAGE STATUS AGE
emqx emqx:5.0 Running 10m
1 2 3 4
The corresponding CRD of EMQX Enterprise in EMQX Operator is EmqxEnterprise, and EmqxEnterprise supports configuring EMQX cluster Service through .spec.serviceTemplate field. For the specific description of the serviceTemplate field, please refer to serviceTemplate(opens new window).
EMQX will open 6 listeners by default, namely: mqtt-ssl-8883 corresponds to port 8883, mqtt-tcp-1883 corresponds to port 1883, http-dashboard-18083 corresponds to port 18083, http-management-8081 corresponds to port 8081,mqtt-ws-8083 corresponds to port 8083 and mqtt-wss-8084 corresponds to port 8084. EMQX Operator will automatically inject the default listener information into the Service when creating the Service, but when there is a conflict between the Service configured by the user and the listener configured by EMQX (the name or port field is repeated), EMQX Operator will use the user's configuration prevail.
Save the above content as emqx.yaml and execute the following command to deploy the EMQX cluster:
$ kubectl apply -f emqx.yaml
emqxenterprise.apps.emqx.io/emqx-ee created
1 2 3
Check the status of the EMQX cluster and make sure that STATUS is Running, which may take some time to wait for the EMQX cluster to be ready.
$ kubectl get emqxenterprises
NAME STATUS AGE
emqx-ee Running 8m33s
Open the browser, enter the host IP and port 32012 where the EMQX Pod is located, log in to the EMQX cluster Dashboard (Dashboard default user name: admin, default password: public), enter the Dashboard and click Configuration → Listeners to enter the listener page, We first click the Add Listener button to add a listener named to test and port 1884, as shown in the figure below:
Then click the Add button to create the listener, as shown in the following figure:
As can be seen from the figure, the test listener we created has taken effect.
Check whether the newly added listener is injected into the Service
kubectl get svc -l apps.emqx.io/instance=emqx
1
The output is similar to:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
emqx-dashboard NodePort 10.105.110.235 <none>18083:32012/TCP 13m
emqx-listeners NodePort 10.106.1.58 <none>1883:32010/TCP,14567:32011/UDP,1884:30763/TCP 12m
1 2 3
From the output results, we can see that the newly added listener 1884 has been injected into the emqx-listeners Service.