Solutions
LE Sparkplug Edge Node
Deploying The Solution
15min
this guide provides step by step instructions to set up and deploy the le sparkplug edge node solution on your litmus edge device prerequisites before proceeding, ensure you have the following litmus edge 3 16 x or later a litmus edge api token see the create api token guide mqtt broker connection details (url, username, password) the solution supports mqtt protocol versions 3 1 0 and 3 1 1 1\ upload the image to litmus edge download the le sparkplug edge node image ( le sparkplug edge node vx x x ) from the central portal website via the download button log in to your litmus edge instance and navigate to applications > images click the upload image (+) icon, select upload , choose the downloaded image file ( le sparkplug x x x tar gz ), and click import the image may take a few moments to appear in the list 2\ deploy the application you can deploy the application using either a configuration file (recommended) or environment variables method 1 using a configuration file (recommended) this method uses a json file to manage all configuration settings, making it easier to handle complex configurations like tls download the configuration flow le sparkplug edge node flow from the download page update the config file with valid configuration values and trigger the flow to create the file next, see the run the docker container section below for optional settings like enabling primary host support, store and forward, configuring tls, or adjusting logging levels, add the corresponding fields to this json file refer to the environment variables docid\ egbn1fdy 0yclbgpc ja documentation for all available fields and the tls certs docid 8gggoql nhxixhrfztgb7 guide for tls setup run the docker container use the docker run command, mounting the directory containing config json to /le sparkplug/data/ inside the container replace \<imgname> \<tagname> with the actual image name and tag you uploaded (e g , us docker pkg dev/litmus customer facing/litmus solutions/le sparkplug 1 4 4 ) docker run d name le sparkplug network host v /var/lib/customer/sparkplug/ /le sparkplug/data/ \<imgname> \<tagname> method 2 using environment variables this method is an alternative if you prefer not to use a configuration file required settings are passed directly via e flags run the docker container provide the required configuration values using environment variables replace placeholders ( < > ) and \<imgname> \<tagname> docker run example docker run d name le sparkplug network host e edge api token="\<your litmus edge api token>" e group id="mygroup" e node id="myedgenode" e mqtt servers='\[{\\"url\\" \\"tcp\ //\<broker ip or hostname> 1883\\",\\"user\\" \\"\<mqtt username>\\",\\"password\\" \\"\<mqtt password>\\"}]' \<imgname> \<tagname> the mqtt servers value is a json string ensure proper escaping of quotes! for optional settings, add more e flags refer to the environment variables docid\ egbn1fdy 0yclbgpc ja documentation for all available environment variables to configure tls, you need to embed the base64 encoded certificates within the mqtt servers json string see the tls certs docid 8gggoql nhxixhrfztgb7 guide that's it! your le sparkplug edge node application should now be running on your litmus edge device 🎉 optional running externally (outside litmus edge) you can also run the le sparkplug edge node container on a separate machine (e g , your laptop, a server) and connect it back to your litmus edge instance this requires specific prerequisites and configuration adjustments prerequisites for running externally nats proxy enabled ensure the nats proxy is enabled on your target litmus edge device navigate to system > services > nats proxy in the litmus edge ui and enable it if necessary api account token you need an api account token follow the instructions in the create an api account guide to generate one this token is used in the nats url edge hostname/ip you need the hostname or ip address of your litmus edge device, accessible from the machine where you will run the container configuration when running externally, you must provide two additional configuration parameters edge hostname (json) / edge hostname (env var) the hostname or ip address of your litmus edge device nats url (json) / nats url (env var) the connection string for the litmus edge nats broker format tls\ //admin \<your api account token>@\<edge hostname> 4222 if the machine running the container is on the same local network as the litmus edge device and you encounter tls certificate errors, try replacing tls\ // with nats\ // in the nats url / nats url for example nats\ //admin \<your api account token>@\<edge hostname> 4222 deployment examples for external execution method 1 using a configuration file (recommended) update your config json file { "edge api token" "\<your litmus edge api token>", "edge hostname" "\<your litmus edge hostname or ip>", // added for external connection "nats url" "tls\ //admin \<your api account token>@\<your litmus edge hostname or ip> 4222", // added for external connection "group id" "mygroup", "node id" "mynode", "mqtt" { "servers" \[ { "url" "tcp\ //\<broker ip or hostname> 1883", "user" "\<mqtt username>", "password" "\<mqtt password>" } ] } // add other optional fields as needed (primary host support, etc ) } run the container, mounting the config file (ensure the container can access the path) \# run on your external machine docker run d name le sparkplug external v /path/to/your/config/dir/ /le sparkplug/data/ us docker pkg dev/litmus customer facing/litmus solutions/le sparkplug 1 4 4 adjust the volume path ( /path/to/your/config/dir/ ) to the location of your config json on the external machine /path/to/your/config/dir/ must contain a folder named config with the config file config json method 2 using environment variables run the container on your external machine with additional environment variables \# run on your external machine docker run d name le sparkplug external e edge api token="\<your litmus edge api token>" e edge hostname="\<your litmus edge hostname or ip>" e nats url="tls\ //admin \<your api account token>@\<your litmus edge hostname or ip> 4222" e group id="mygroup" e node id="mynode" e mqtt servers='\[{\\"url\\" \\"tcp\ //\<broker ip or hostname> 1883\\",\\"user\\" \\"\<mqtt username>\\",\\"password\\" \\"\<mqtt password>\\"}]' us docker pkg dev/litmus customer facing/litmus solutions/le sparkplug 1 4 4 add other optional e flags as needed 3\ verify the deployment to verify that the container is running correctly, you can check the logs docker logs le sparkplug you should see logs indicating that the container is running and connected to the mqtt broker