# Access EMQX Cluster by LoadBalancer

# Task Target

How to access EMQX cluster by LoadBalancer.

# Configure EMQX Cluster

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:

# Use MQTT X Client to Connect EMQX Cluster

Check EMQX service

$ kubectl get svc -l apps.emqx.io/instance=emqx

NAME             TYPE       CLUSTER-IP       EXTERNAL-IP            PORT(S)                          AGE
emqx-dashboard   NodePort   10.101.225.238   183.134.197.178        18083:32012/TCP                  32s
emqx-listeners   NodePort   10.97.59.150     183.134.197.178        1883:32010/TCP                   10s
1
2
3
4
5

use MQTT X Cli to connect EMQX

$ mqttx conn -h 183.134.197.178
[11:16:40] › …  Connecting...
[11:16:41] › ✔  Connected
1
2
3

# Add New listeners via EMQX Dashboard

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.