Creating edge services
With IBM Edge Computing for Devices, you can develop services within Docker containers for your edge machines. You can use any appropriate Linux base, programming languages, libraries, or utilities to create your edge services.
After you push, sign, and publish your services, IBM Edge Computing for Devices uses fully autonomous agents on your edge machines to download, validate, configure, install, and monitor your services. With these agents, you can focus on developing the software that you need for your business, and leave the service software lifecycle management to the agents.
IBM Edge Computing for Devices is based on the open source Horizon project. For more information, see Open Horizon .
IBM Edge Computing for Devices uses the hzn
Horizon Linux command for running some processes.
Before you begin
-
Configure your development host for use with IBM Edge Computing for Devices. Install the Horizon software on your machine and register your machine with Horizon exchange. For more information, see:
By completing these tasks, you also ensure that the local Horizon agent is running on your development host. After you complete this process, you can choose to unregister your development host before you continue with the edge service development process.
Configuring your development host environment as an edge node is not required for development, but the following steps assume that your development host is set up as an edge node. By following the registration process on your development host, you configure your host environment to work with IBM Edge Computing for Devices. If you do not want to register your development host, omit the step that involves the
hzn register
command when you are completing the task to register your machine. -
Set up a Docker Hub ID. For more information about signing up for an ID, see Docker Hub .
Note: The examples that are used or referenced in the following steps can be built on only the following hardware architectures:
- ARM (32-bit)
- ARM (64-bit)
- x86_64 machines or virtual machines
IBM Edge Computing for Devices supports other architectures, but the provided development examples are only supported on the listed architectures. The following steps are based on an environment that uses the listed architecture. If you use a different
architecture, the commands and values that you need to use can be different. For instance, if you use a MacOS architecture, steps that reference Linux commands and tools are different. As an example, you might need to use an alternative tool to
the standard Linux tools, such as the git
commands, that are used in these steps. The tools that are used are common development tools, which are available through tools like Homebrew on MacOS. For more information about this tool,
see Homebrew .
Procedure
-
Set up your credentials. To publish content in the Horizon exchange, you need to provide the required credentials.
Note: The procedures for each development example require your credentials to be set up based on the following steps. For more information about these development examples, see IBM Edge Computing for Devices examples.
When you are configuring your IBM Edge Computing for Devices credentials, use shell environment variables. By using these variables, the
hzn
command can retrieve your credentials from the environment so that you do not need to specify the credentials for eachhzn
command that you run.Run the following
export
commands to set your credentials:export HZN_ORG_ID="<organization>" export HZN_EXCHANGE_USER_AUTH="iamapikey:<apikey>" hzn exchange user list
Substitute your own credentials for
<organization>
and<apikey>
. For IBM Cloud Private) environments, the value for your<organization>
is typically your cluster name. -
Verify that your credentials work by running the
hzn exchange user list
command. This command returns details about your user account within Horizon exchange). -
Edit the
horizon/hzn.json
file to set up more credentials. Specifically, edit the following two variables in the file by substituting your values for<organization>
and<dockerhubid>
):{ "HZN_ORG_ID": "<organization>", "MetadataVars": { "DOCKER_IMAGE_BASE": "<dockerhubid>/helloworld", "SERVICE_NAME": "helloworld", "SERVICE_VERSION": "1.0.0" } }
-
Log in to Docker Hub by using the Docker Hub ID that you previously created by running the following command:
docker login -u '<dockerhubid>'
Output example:
docker login -u '<dockerhubid>' Password: WARNING! Your password will be stored unencrypted in /home/pi/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded
Note: If you are creating a service on a MacOS development environment, you need to go to the Docker Preferences > General, and turn off the Securely store Docker logins in macOS keychain setting. This setting change is required on only MacOS environments because the MacOS keychain feature prevents the
make
commands from using your Docker credentials. -
Create your cryptographic signing keys. All edge services and deployment patterns must be cryptographically signed. If you do not already have an appropriate asymmetric cryptographic signing key pair, you must create a key pair that you can use for signing. If you already have your key pair, ensure that your key pair files are appropriately named.
If you need to create a new key pair, run the following command:
hzn key create "<x509-org>" "<x509-cn>"
Substitute appropriate values for the
<x509-org>
property. Typically, the value for<x509-org>
can be your company name, and the value for<x509-cn>
can be your email address.This command creates the following two files:
~/.hzn/keys/service.private.key
~/.hzn/keys/service.public.pem
-
If you are using an existing key pair, copy your version of these files into the preceding locations so that the
hzn exchange ... publish ...
commands can find your key pair files.
What to do next
With your credentials and signing keys, go through the provided development examples. These examples walk you through building simple edge services to learn the basics for developing for IBM Edge Computing for Devices. Follow these examples before you build your own edge services and containers or review the more detailed developer information:
After you finish building these example services, review the following documentation for more detailed information about developing services for IBM Edge Computing for Devices: