This is a simple example of using and creating a Horizon edge service.
- Preconditions for Using the Hello World Example Edge Service
- Using the Hello World Example Edge Service with Deployment Pattern
- Using the Hello World Example Edge Service with Deployment Policy
- Creating Your Own Hello World Edge Service
- Further Learning - to see more Horizon features demonstrated, continue on to the cpu2evtstreams example.
If you haven't done so already, you must do these steps before proceeding with the helloworld example:
-
Install the Horizon management infrastructure (exchange and agbot).
-
Install the Horizon agent on your edge device and configure it to point to your Horizon exchange.
-
As part of the infrasctucture installation process for IBM Edge Computing Manager a file called
agent-install.cfg
was created that contains the values forHZN_ORG_ID
and the exchange and css url values. Locate this file and set those environment variables in your shell now:
eval export $(cat agent-install.cfg)
- Note: if for some reason you disconnected from ssh or your command line closes, run the above command again to set the required environment variables.
- In addition to the file above, an API key associated with your Horizon instance would have been created, set the exchange user credentials, and verify them:
export HZN_EXCHANGE_USER_AUTH=iamapikey:<horizon-API-key>
hzn exchange user list
- Choose an ID and token for your edge node, create it, and verify it:
export HZN_EXCHANGE_NODE_AUTH="<choose-any-node-id>:<choose-any-node-token>"
hzn exchange node create -n $HZN_EXCHANGE_NODE_AUTH
hzn exchange node confirm
- If you have not done so already, unregister your node before moving on:
hzn unregister -f
- Register your edge node with Horizon to use the helloworld pattern:
hzn register -p IBM/pattern-ibm.helloworld -s ibm.helloworld --serviceorg IBM
- Note: using the
-s
flag with thehzn register
command will cause Horizon to wait until agreements are formed and the service is running on your edge node to exit, or alert you of any errors encountered during the registration process.
- After the agreement is made, list the docker container edge service that has been started as a result:
sudo docker ps
- See the helloworld service output:
hzn service log -f ibm.helloworld
- Note: Press Ctrl C to stop the command output.
- Unregister your edge node (which will also stop the myhelloworld service):
hzn unregister -f