Connect Local baetyl-broker Service of Edge Node
Background description
Since baetyl 2.1.1, all official applications (baetyl-broker, baetyl-function, and baetyl-rule) are integrated with baetyl-go-sdk by default, baetyl-core is used for issuing the certificate for such official applications, and the certificate issued by baetyl-core is used for the authentication of the inter-service call by default.
If the developers want to access the local baetyl-broker, configure the baetyl-broker, and open the external access. Set the user name and password to access the broker, and bind the host listening port, so that you can access the host_machne_ip:port
using the MQTT Client on any device.
This article explains the above schemes.
## Operation Guide
Install node
Refer to the Getting Started to install the edge node. After the installation command is executed on the edge side, view the system applications in the baetyl-edge-system
namespace through the kubectl
Command<5/>.
root@userver-desk:~# kubectl get pod -n baetyl-edge-system
NAME READY STATUS RESTARTS AGE
baetyl-init-d968b7bb9-c8b22 1/1 Running 0 3h24m
baetyl-core-7d5995f956-7jszr 1/1 Running 0 3h24m
baetyl-rule-5f4d7f964-xprx8 1/1 Running 0 3h24m
baetyl-function-6c7fd69f44-xwnxk 1/1 Running 0 3h24m
baetyl-broker-6f9cbbd794-rb9p7 1/1 Running 0 3h24m
Bing baetyl-broker Port to Local Port 8883
Enter the edge node, click "Application Deployment" to find the baetyl-broker application, and click View as shown in the figure below:
Enter the baetyl-broker Application interface, and click Configure as shown in the figure below:
Add a port mapping record on the Port Mapping ——> Host Port as shown in the figure below:
- Host port: 8883
- Container port: 8883
- Protocol: TCP
Return to the Application Configuration interface, switch to the Data Volume page, and click "baetyl-broker-conf Configuration Volume" as shown in the figure below:
Enter the Configuration Item page, and click Edit as shown in the figure below:
Enter the following configuration information on the conf.yaml configuration interface as shown in the figure below:
session:
sysTopics:
- $link
- $baetyl
logger:
level: debug
encoding: console
listeners:
- address: 'tcp://0.0.0.0:8883'
principals:
- username: test
password: test
permissions:
- action: pub
permit:
- '#'
- action: sub
permit:
- '#'
Configuration parse:
- Add the
8883
listening port for baetyl-broker, and use thetest/test
user name and password to access. This user has thepub/sub
permission of the#
topic- Here, it doesn't have to be port 8883, and it can be any other unused port. You can view whether the port 8883 is occupied through the
netstat -ap | grep 8883
command
Access through MQTT Box
Install MQTT Box on the operating PC, and configure the connection information as shown in the figure below:
Return to MQTT Box. Then, you can see that the connection status is connected. After that, test the message subscription and sending as shown in the following figure: