IndustryFusion SmartBox Gateway Setup and Onboarding Gateway Devices - IndustryFusion/IndustryFusion GitHub Wiki

IOT Agent Device OnBoarding Framework

This Framework Blueprint for Onboarding Gateway Devices for Industry Fusion.

Prerequisites

In order to setup and onboard assets on your gateway you need to do the following: (for access ask Konstantin):

GitHub repos:

IndustryFusion

machine-config repo

platform-launcher (public repo)

Docker Hub:

ibn40/repositories

oisp/repositories

OISP Platform:

https://platform.industry-fusion.com

Install and configure k3s:

Install the Lightweight Kubernetes k3s on gateway (root rights required). For further information on k3s visit https://k3s.io/. Note: Currently each SmartBox-Gateway is used as k3s master. In future versions a local k3s cluster of the gateways on the shopfloor will be used.

curl -sfL https://get.k3s.io | sh -
# Check for Ready node,
takes maybe 30 seconds
k3s kubectl get node

Create namespace k3s:

kubectl create namespace oisp-devices

Create secret for docker hub repository with your docker credentials:

kubectl -n oisp-devices create secret docker-registry regcred --docker-server=docker.io --docker-username=YOUR_DOCKER_USERNAME --docker-password=YOUR_DOCKER_PASSWORD [email protected]

Install python3 and pip3 on your gateway:

sudo apt install python3
sudo apt install python3-pip

Install python packages with pip using requirements file:

pip3 install -r requirements.txt

Store git credentials in cache for 30 days:

git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=2592000'

OISP Platform:

Get access to OISP Platform Dashboard.

Getting started:

  1. Clone this repository under your gateway. oisp-iot-agent git repo(Checkout "development" branch)
  2. Browse to the 'oisp-iot-agent/container/kubernetes/onboarding/' directory.
  3. gatewaydeployment.yaml is the sample gateway device onboarding config repo description file.
  4. Exchange default config.json through IndustryFusion config.json This will set hosts for rest, ws and mqtt correctly.
  5. Create app_config.yaml which should consist of OISP Instance URL and APP Version. Sample app_config.yaml description:
BASE_OISP_INSTANCE: <OISP_BASE_URL>
API_VERSION:   <vX/api>
  1. Create gatewaydeployment.yaml which should consist of Application Name, Deployment Config, Machine Config details for this framework to parse and deploy the devices you want to onboard connected to your gateway. Sample gatewaydeployment.yaml description:
version: <DEPLOYMENT_YAML_VERSION_NUMBER>
namespace: <NAMESPACE_FOR_ALL_DEPLOYMENTS>
CreateDeployments:
- ApplicationName: <DEPLOYMENT_NAME>
    NodeName: <K3S_NODE_NAME>
    ToolVersion: <TOOL_VERSION>
    DeploymentConfig:
        URL: <DEPLOYMENT_GIT_CONFIG_URL>
        Directory: <DEPLOYMENT_CONFIG_GIT_DIRECTORY_NAME>
        GitTag: <DEPLOYMENT_GIT_TAG_OR_COMMITID_OR_BRANCH>
    MachineConfig:
        URL: <MACHINE_GIT_CONFIG_URL>,
        Directory: <MACHINE_CONFIG_GIT_DIRECTORY_NAME>,
        GitTag: <MACHINE_CONFIG_TAG_OR_COMMITID_OR_BRANCH>
  1. Please export KUBECONFIG to correct k3s_cluster_config.yaml
export KUBECONFIG=/home/tk/src/tools/oisp-iot-agent/container/kubernetes/onboarding/k3s_cluster_config.yaml
  1. Initiate the Deployment process based on three actions; create, update or delete. (deviceonboarding.py can be found here: https://github.com/Open-IoT-Service-Platform/oisp-iot-agent/tree/development/container/kubernetes/onboarding )
python3 deviceonboarding.py --action create --deployfilepath gatewaydeployment.yaml
OR
python3 deviceonboarding.py -a create -d gatewaydeployment.yaml
===================================================================================
python3 deviceonboarding.py --action update --deployfilepath gatewaydeployment.yaml
OR
python3 deviceonboarding.py -a update -d gatewaydeployment.yaml
===================================================================================
python3 deviceonboarding.py --action delete --deployfilepath gatewaydeployment.yaml
OR
python3 deviceonboarding.py -a delete -d gatewaydeployment.yaml
  1. Once the onboarding script it initiated it will ask you for OISP platform credentials.
Gateway:~/tools $python3 deviceonboarding.py --action delete --deployfilepath gatewaydeployment.yaml
Deleting Pods....
Enter OISP User Credentials
Username: [email protected]
Password:
Namespace oisp-devices already exists. Continue.
configmap "global-devices-config" deleted
configmap/global-devices-config created
secret "global-devices-secret" deleted
...........
  1. After Onboarding is complete you can see the deployment pod status using following command. Below is the current gateway onboarding status with Gateway and Machine connected to it.
kubectl -n oisp-devices get pods -o wide
NAME                                READY   STATUS    RESTARTS   AGE     IP            NODE     NOMINATED NODE   READINESS GATES
plasmacutter-mcc-58997d79c5-lgj79   4/4     Running   9          41d     10.42.0.120   tkgw00   <none>           <none>
gasversorgung-5b96458747-zhqlq      4/4     Running   0          12d     10.42.2.95    tkgw04   <none>           <none>
lasercutter-74d76dff95-csrll        4/4     Running   0          12d     10.42.3.123   tkgw06   <none>           <none>
filteringunit-5c89579b78-64rpm      4/4     Running   0          12d     10.42.1.80    tkgw03   <none>           <none>
airtracker-5d8c6b999b-vb98v         4/4     Running   4          7d11h   10.42.4.70    tkgw07   <none>           <none>
plasmacutter-df8cbcb69-vjbnl        4/4     Running   3          12d     10.42.3.122   tkgw06   <none>           <none>

  1. Get detailed information on pods and containers (exchange with correct name of pod and container e.g. oisp-iot-agent)
kubectl -n oisp-devices describe pods airtracker-deployment-testsensor-7b5bcfb77d-5knnf
kubectl -n oisp-devices logs airtracker-deployment-testsensor-7b5bcfb77d-w55dk oisp-iot-agent
⚠️ **GitHub.com Fallback** ⚠️