BeeOS Docs
  • Welcome
  • Concepts
    • Overview
    • Bee agents
    • Hive server
      • Bee provisioning
        • Scheduler
      • Workflows
      • Gateway
    • Beekeeper server
    • Use cases
  • Using BeeOS
    • Installing and running BeeOS
      • Installing a hive server
      • Running a hive server
      • Running bee agents
Powered by GitBook
On this page
  • Start hive
  • Configure hive
  • Registering bees
  1. Using BeeOS
  2. Installing and running BeeOS

Running a hive server

How to start and configure a hive server

PreviousInstalling a hive serverNextRunning bee agents

Last updated 2 years ago

To make things easier we start running a standalone server directly from the command line as an example. We are not using snap installation or container deployment. We also do not use a cluster-based configuration for high availability (see corresponding section for more information).

[TBD: Explain Docker client example]

Start hive

The hive needs a hive.yaml configuration file. This file contains the necessary parameters to be able to start the server. By default, when it starts it will look for a file called hive.yaml in the same location where the executable is located. This behavior can be changed using the --config (-c) option to specify a path to a configuration file other than the default.

hive -c /etc/beeos/beehive.yaml

The configuration file is of type YAML. It contains entries to configure the provider to use to store internal data, authentication options, cluster settings, etc. For detailed information about the options available in the configuration file, see the hive configuration section.

Below is a basic configuration file that saves the internal hive data in a data.db file in the same location where the executable is located, it will use the HTTP API without TLS or authentication, that is, the command line beectl can be connected without login.

For hive production configurations is advisable to use authentication and TLS encryption using certificates for communications.

hive.yaml
store: local
storeURI: "./data.db"
api: "http"

Once we start the hive, it shows us startup information through the console to see the applied configuration and information about the services that are running.

INFO[0000] STORE: local                                 
INFO[0000] STORE URI: ./data.db                         
INFO[0000] API: http                                    
INFO[0000] ----------------------------------------------------------------------------------------------- 
INFO[0000]                                              
INFO[0000]  #####                           #####     #####       
INFO[0000]  ##   ##                       ##     ##  ##           
INFO[0000]  ##   ##     ####      ####    ##     ##  ##           
INFO[0000]  #######   ##    ##  ##    ##  ##     ##   ####        
INFO[0000]  ##    ##  ########  ########  ##     ##       ##      
INFO[0000]  ##    ##  ##        ##        ##     ##       ##      
INFO[0000]  #######    #####     #####      #####    #####        
INFO[0000]                                              
INFO[0000] ----------------------------------------------------------------------------------------------- 
INFO[0000] -- BeeOS Server (v0.7.19) --------------------------------------------------------------------- 
INFO[0000] ----------------------------------------------------------------------------------------------- 
INFO[0000] DB opened                                    
INFO[0000] NATS Server started                          
INFO[0000] HTTP Server started                          
INFO[0000] BEEKEEPER Service started                    
INFO[0000] Operator public key: OB46ACFBW3PY3CUOQDPU5DAOHUYSHB5NIPOMPSQCQ2FCO2FLVVCRGFLM 
INFO[0000] System account public key: ABAV66UYXYN5FLSE4H5L7KGT57GTFSLGZYGVA3764M6M4NMMTPCYAX6C 
INFO[0000] ----------------------------------------------------------------------------------------------- 

A hive can work in beekeeper mode allowing the management of other hives and deployment of configurations remotely to hives and its connected bees using the scheduling services. See working with beekeeper services section.

Configure hive

At that moment the hive server is running and waiting to be configured to allow the connection of bees. The beectl command line interface (or HTTP API) is used to configure the server and register bees.

Registering bees

Bees must be registered to be authenticated during connection to the hive. To do this we will use the following beectl command.

beectl set bee -b bee1 -n MyBee

The set command adds or updates bees. In that case, the command is adding a new bee using bee1 as ID and MyBee as its name. The set bee subcommand has other options like describing the bee or assigning it to a specific hub other than the default one.

Once the bee is registered, the ls command can be used to list the registered bees and their current state.

beectl ls bees
ID       Hub       State      Resources   Last sync    Swarm    Name              
bee1     default   Unbound    0           (no sync)    No       MyBee  

The Unbound state shown above means the bee has not yet been assigned a pubic key. Therefore the bee will not be able to connect and be authenticated to the server. A pair of public and private keys are needed to allow the bee agent to be connected to the hive.

Generating and binding keys

[TBD: NKeys generations]

There are two ways to create the key pair. The first one is auto generating the keys while binding the public key to a bee using the --auto-generate flag. In that case the command outputs an initialisation file ready to be used by the bee while starting.

beectl bind key -b bee1 --auto-generate -o mybee.yaml

If no --output (-o) flag is provided the name of the file is the bee ID (in that case bee1.yaml). The output contains a YAML file with the following contents:

id: bee1
key: SUAIQUXSPI4SOQVGTB5GV5FWXZ7D4M5WC5FCH2CTDFH2IZT5QZUQZDUT54
hive: localhost:3333

The key field is the seed of the key pair. The public key can be extracted from this seed key. You can see the public key executing a get command to show the bee information.

beectl get bee -b bee1
Bee information                                                                  
ID                     bee1                                                   
Name                   MyBee                                                
Description            (No available)                                
Hub                    default                                                   
Public keys            UDZZ57E7NQFXSJ72M56PWEUZA6H4S6FZTED4GFDNJLPGJ6FTTMF6YDCW  
Configuration version  (No configured yet)                                                        
Resources              (No resources uploaded)                                   
State                  Disconnected                                              
Last synchronization   (No sync)                                       
Swarm                  No                                                        
Schemas                (No available)  

Connection state is Disconnected instead of Unbound and a public key appears at Public keys section. Explain swarm and balanced bees and refer to advanced topic (collection of public keys...)

The second way is to provide manually the public key from an available owned key pair. The command bind helps to bind a given public key with a registered bee.

beectl bind key -b bee1 -k UDZZ57E7NQFXSJ72M56PWEUZA6H4S6FZTED4GFDNJLPGJ6FTTMF6YDCW

To manually generate a public/private key pair the following command should be executed:

beectl gen keys
Generated NKey:
Public Key: UDZZ57E7NQFXSJ72M56PWEUZA6H4S6FZTED4GFDNJLPGJ6FTTMF6YDCW
Private Seed: SUAIQUXSPI4SOQVGTB5GV5FWXZ7D4M5WC5FCH2CTDFH2IZT5QZUQZDUT54

The above gen keys command prints a key pair to the console. If you prefer not to print the keys for security reasons, they can be generated and stored in a file (using --output (-o) flag specifying a path to a file to be created or overwritten).

It is recommended to store the private seed key in a safety place. The seed key should only be accessed by the user executing the bee in production environments.

Docker client bee connected to a hive server