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.

Edge and cloud development

IBM Edge Computing for Devices is based on the open source Horizon project. For more information, see Open Horizon Opens in a new tab. IBM Edge Computing for Devices uses the hzn Horizon Linux command for running some processes.

Before you begin

Note: The examples that are used or referenced in the following steps can be built on only the following hardware architectures:

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 Opens in a new tab.

Procedure

  1. 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 each hzn 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.

  2. Verify that your credentials work by running the hzn exchange user list command. This command returns details about your user account within Horizon exchange).

  3. 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"
         }
     }
    
  4. 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.

  5. 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
  6. 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: